Skip to content

Commit 9a3a8a0

Browse files
committed
blkdev.cc: fix STRING_OVERFLOW
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 <danny.al-gaaf@bisect.de>
1 parent e221463 commit 9a3a8a0

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/common/blkdev.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ int get_block_device_base(const char *dev, char *out, size_t out_len)
5757
if (strncmp(dev, "/dev/", 5) != 0)
5858
return -EINVAL;
5959

60-
strcpy(devname, dev + 5);
60+
strncpy(devname, dev + 5, PATH_MAX-1);
61+
devname[PATH_MAX-1] = '\0';
6162
for (p = devname; *p; ++p)
6263
if (*p == '/')
6364
*p = '!';

0 commit comments

Comments
 (0)