diff options
author | Ryan Long <ryan.long@oarcorp.com> | 2021-05-17 16:58:14 -0400 |
---|---|---|
committer | Joel Sherrill <joel@rtems.org> | 2021-09-29 10:00:22 -0500 |
commit | 05dab02722b7df3f1f231884e5f58cc7be969b75 (patch) | |
tree | b89c63e59fff20554df8c4abddc926ff33bb6c65 /misc | |
parent | TraceWriterQEMU.h: Fix formatting (diff) | |
download | rtems-tools-05dab02722b7df3f1f231884e5f58cc7be969b75.tar.bz2 |
rtems-bin2c.c: Check length of buffer to be copied
CID 1063892: Copy into fixed size buffer in process().
Closes #4424
Diffstat (limited to 'misc')
-rw-r--r-- | misc/bin2c/rtems-bin2c.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/misc/bin2c/rtems-bin2c.c b/misc/bin2c/rtems-bin2c.c index 8e32d25..462ecf0 100644 --- a/misc/bin2c/rtems-bin2c.c +++ b/misc/bin2c/rtems-bin2c.c @@ -141,6 +141,19 @@ void process(const char *ifname, const char *ofname, const char *forced_name) char *ifbasename; ifbasename = basename(ifbasename_to_free); + /* Ensure length of ifbasename is shorter than length of buf */ + if (strlen(ifbasename) > PATH_MAX+1) { + fprintf( + stderr, + "error: Base name of %s is too long.\n", + ifbasename + ); + fclose(ifile); + if ( createC ) { fclose(ocfile); } + if ( createH ) { fclose(ohfile); } + exit(1); + } + strcpy(buf, ifbasename); sanitize_file_name(buf); |