From: Eric Andersen Date: Thu, 6 Jun 2002 14:36:07 +0000 (-0000) Subject: Fix buffer overflows noted by Gerardo Puga X-Git-Tag: 0_60_4~166 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=fe1ef2bc62883539f37e0070f62c765602232a77;p=oweals%2Fbusybox.git Fix buffer overflows noted by Gerardo Puga -Erik --- diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c index 4e50a6d71..f55995685 100644 --- a/miscutils/makedevs.c +++ b/miscutils/makedevs.c @@ -52,9 +52,13 @@ int makedevs_main(int argc, char **argv) if (type[0] != 'f') dev = (major << 8) | Sminor; - strcpy(devname, basedev); + safe_strncpy(devname, basedev, sizeof(devname)); if (sbase == 0) { + int len; + len = strlen(devname); + if (S > 10000 || len > (sizeof(devname)-6)) + error_msg_and_die("%s: number too large", buf); sprintf(buf, "%d", S); strcat(devname, buf); } else {