]> www.infradead.org Git - mtd-utils.git/commitdiff
mtd-utils: Add checks to code that copies strings into fixed sized buffers
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Sat, 25 Jan 2020 13:46:31 +0000 (14:46 +0100)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Sun, 9 Feb 2020 21:13:18 +0000 (22:13 +0100)
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
jffsX-utils/jffs2dump.c
ubi-utils/ubirename.c

index ad7a9e32a7cac2b183a5fb4fd79efc656be4fcf8..d30b59f69dbcb6f5482e3fe0bfdfff0a27b64720 100644 (file)
@@ -149,7 +149,8 @@ static void process_options (int argc, char *argv[])
                                break;
                        case 'e':
                                convertendian = 1;
-                               strcpy (cnvfile, optarg);
+                               strncpy (cnvfile, optarg, sizeof(cnvfile) - 1);
+                               cnvfile[sizeof(cnvfile) - 1] = '\0';
                                break;
                        case 'r':
                                recalccrc = 1;
index f88ef82ce5171166420cbe18bef472493ab495ac..97bf030b70693dbe6e03582fcc9e3ecf238ea671 100644 (file)
@@ -126,6 +126,13 @@ int main(int argc, char * const argv[])
 
                rnvol.ents[count].vol_id = err;
                rnvol.ents[count].name_len = strlen(argv[i + 1]);
+
+               if (rnvol.ents[count].name_len >=
+                   sizeof(rnvol.ents[count].name)) {
+                       errmsg("\"%s\" volume name too long", argv[i + 1]);
+                       goto out_libubi;
+               }
+
                strcpy(rnvol.ents[count++].name, argv[i + 1]);
        }