From: Roy Marples Date: Fri, 7 Feb 2014 21:04:09 +0000 (+0000) Subject: Ensure fscanf does not overflow. X-Git-Tag: v6.3.0~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71ddb604c5dac154292fd1e0a282eccd500559f9;p=thirdparty%2Fdhcpcd.git Ensure fscanf does not overflow. --- diff --git a/platform-linux.c b/platform-linux.c index 8f15e975..6fe470c6 100644 --- a/platform-linux.c +++ b/platform-linux.c @@ -83,7 +83,7 @@ int hardware_platform(char *str, size_t len) { FILE *fp; - char buf[255]; + char buf[256]; if (mproc == NULL) { errno = EINVAL; @@ -94,9 +94,9 @@ hardware_platform(char *str, size_t len) if (fp == NULL) return -1; - while (fscanf(fp, "%s : ", buf) != EOF) { + while (fscanf(fp, "%255s : ", buf) != EOF) { if (strncmp(buf, mproc, strlen(mproc)) == 0) { - fscanf(fp, "%s", buf); + fscanf(fp, "%255s", buf); fclose(fp); return snprintf(str, len, ":%s", buf); }