diff options
author | Mateusz Kusiak <mateusz.kusiak@intel.com> | 2021-08-12 13:48:48 +0200 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2021-08-13 21:21:12 +0200 |
commit | feeb2785e67f084cb5d706fe5f074ade50bece78 (patch) | |
tree | 69a0a80e0f17550e7c24afe2b580df196dd22809 /util.c | |
parent | Release mdadm-4.2-rc2 (diff) | |
download | mdadm-feeb2785e67f084cb5d706fe5f074ade50bece78.tar.xz mdadm-feeb2785e67f084cb5d706fe5f074ade50bece78.zip |
Utils: Change sprintf to snprintf
Using sprintf can cause segmentation fault by exceeding the size of buffer array.
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -947,12 +947,12 @@ dev_t devnm2devid(char *devnm) /* First look in /sys/block/$DEVNM/dev for %d:%d * If that fails, try parsing out a number */ - char path[100]; + char path[PATH_MAX]; char *ep; int fd; int mjr,mnr; - sprintf(path, "/sys/block/%s/dev", devnm); + snprintf(path, sizeof(path), "/sys/block/%s/dev", devnm); fd = open(path, O_RDONLY); if (fd >= 0) { char buf[20]; |