diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-10-06 20:01:29 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-10-06 20:01:29 -0700 |
commit | fd561bf3a80a9a23c130f11d26e93a4fded6d464 (patch) | |
tree | 27ca4a445e352e5d7de31dd406935424033bc138 | |
parent | be9658d3380bbdee73a687d74a18ae22c8272ac5 (diff) |
rgb.c: if filename is too long, report error instead of truncating
Avoid possibly creating a file of unknown name/location
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | rgb.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -80,6 +80,13 @@ main(int argc, char **argv) else dbname = RGB_DB; + if (strlen(dbname) > (sizeof(name) - 5)) { + fprintf (stderr, + "%s: dbm file name too long: \"%s\" (%lu max allowed)\n", + ProgramName, dbname, sizeof(name) - 5); + exit (1); + } + snprintf (name, sizeof(name), "%s.dir", dbname); fd = open (name, O_WRONLY|O_CREAT, 0666); if (fd < 0) { |