summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-01-25 14:46:31 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-09 22:13:18 +0100
commit3ea4705086b9b26a4acde7e83eb05be248ade503 (patch)
treeb232ba409c3cb9b14b42d5f7ac93545a3a16d34e
parentdcfd984d8e09db9d5a7b4d121d914442966c254f (diff)
mtd-utils: Add checks to code that copies strings into fixed sized buffers
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--jffsX-utils/jffs2dump.c3
-rw-r--r--ubi-utils/ubirename.c7
2 files changed, 9 insertions, 1 deletions
diff --git a/jffsX-utils/jffs2dump.c b/jffsX-utils/jffs2dump.c
index ad7a9e3..d30b59f 100644
--- a/jffsX-utils/jffs2dump.c
+++ b/jffsX-utils/jffs2dump.c
@@ -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;
diff --git a/ubi-utils/ubirename.c b/ubi-utils/ubirename.c
index f88ef82..97bf030 100644
--- a/ubi-utils/ubirename.c
+++ b/ubi-utils/ubirename.c
@@ -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]);
}