]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Ensure fscanf does not overflow.
authorRoy Marples <roy@marples.name>
Fri, 7 Feb 2014 21:04:09 +0000 (21:04 +0000)
committerRoy Marples <roy@marples.name>
Fri, 7 Feb 2014 21:04:09 +0000 (21:04 +0000)
platform-linux.c

index 8f15e975e8696c822ddefd190d0e06f45674c700..6fe470c6de183ff3b4576c60d6decf0e2e7a2b81 100644 (file)
@@ -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);
                }