From 6b7ceb36a47ce148f4dd2f4e63c717c8593f0cea Mon Sep 17 00:00:00 2001 From: Qualys Security Advisory Date: Thu, 1 Jan 1970 00:00:00 +0000 Subject: [PATCH] proc/devname.c: Never write more than "chop" characters. This should be guaranteed by "tmp[chop] = '\0';" and "if(!c) break;" but this patch adds a very easy belt-and-suspenders check. --- proc/devname.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proc/devname.c b/proc/devname.c index f673a417..08ed131d 100644 --- a/proc/devname.c +++ b/proc/devname.c @@ -351,7 +351,7 @@ abbrev: if(chop + (unsigned long)(tmp-buf) < sizeof buf) tmp[chop] = '\0'; /* replace non-ASCII characters with '?' and return the number of chars */ - for(;;){ + while(i < chop){ c = *tmp; tmp++; if(!c) break;