Skip to content

Commit

Permalink
blkdev.cc: fix STRING_OVERFLOW
Browse files Browse the repository at this point in the history
Fix for:

CID 1258439 (#1 of 1): Copy into fixed size buffer (STRING_OVERFLOW)
 2. fixed_size_dest: You might overrun the 4096 byte fixed-size
    string devname by copying dev + 5 without checking the length.

Signed-off-by: Danny Al-Gaaf <[email protected]>
  • Loading branch information
dalgaaf committed Mar 17, 2015
1 parent e221463 commit 9a3a8a0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/common/blkdev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ int get_block_device_base(const char *dev, char *out, size_t out_len)
if (strncmp(dev, "/dev/", 5) != 0)
return -EINVAL;

strcpy(devname, dev + 5);
strncpy(devname, dev + 5, PATH_MAX-1);
devname[PATH_MAX-1] = '\0';
for (p = devname; *p; ++p)
if (*p == '/')
*p = '!';
Expand Down

0 comments on commit 9a3a8a0

Please sign in to comment.