summaryrefslogtreecommitdiffstats
path: root/src/local.c
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2014-10-19 20:18:02 +0200
committerPali Rohár <pali.rohar@gmail.com>2014-10-19 20:18:02 +0200
commita8986bf631aff030483c695bfb1eed1584e73677 (patch)
tree463b1baf80121fbddcfec6b3381c61172b520189 /src/local.c
parent9a1f63c5aed6e197033747e64d85e471aea3402f (diff)
download0xFFFF-a8986bf631aff030483c695bfb1eed1584e73677.tar.bz2
local: Check return value of snprintf
Diffstat (limited to 'src/local.c')
-rw-r--r--src/local.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/local.c b/src/local.c
index 4d28833..86d3b78 100644
--- a/src/local.c
+++ b/src/local.c
@@ -316,7 +316,8 @@ int local_dump_image(enum image_type image, const char * file) {
while ( ( dirent = readdir(dir) ) ) {
- snprintf(buf, sizeof(buf), "/sys/class/mmc_host/%s/slot_name", dirent->d_name);
+ if ( snprintf(buf, sizeof(buf), "/sys/class/mmc_host/%s/slot_name", dirent->d_name) <= 0 )
+ continue;
fd = open(buf, O_RDONLY);
if ( fd < 0 )
@@ -330,7 +331,8 @@ int local_dump_image(enum image_type image, const char * file) {
if ( strncmp(buf, "internal", strlen("internal")) != 0 )
continue;
- snprintf(buf, sizeof(buf), "/sys/class/mmc_host/%s/%s:0001/", dirent->d_name, dirent->d_name);
+ if ( snprintf(buf, sizeof(buf), "/sys/class/mmc_host/%s/%s:0001/", dirent->d_name, dirent->d_name) <= 0 )
+ continue;
dir2 = opendir(buf);
if ( ! dir2 )
@@ -341,7 +343,8 @@ int local_dump_image(enum image_type image, const char * file) {
if ( strncmp(dirent2->d_name, "block:mmcblk", strlen("block:mmcblk")) != 0 )
continue;
- snprintf(buf, sizeof(buf), "/sys/class/mmc_host/%s/%s:0001/%s/dev", dirent->d_name, dirent->d_name, dirent2->d_name);
+ if ( snprintf(buf, sizeof(buf), "/sys/class/mmc_host/%s/%s:0001/%s/dev", dirent->d_name, dirent->d_name, dirent2->d_name) <= 0 )
+ continue;
f = fopen(buf, "r");
if ( ! f )
@@ -385,7 +388,8 @@ int local_dump_image(enum image_type image, const char * file) {
while ( ( dirent = readdir(dir) ) ) {
- snprintf(buf, sizeof(buf), "/dev/%s", dirent->d_name);
+ if ( snprintf(buf, sizeof(buf), "/dev/%s", dirent->d_name) <= 0 )
+ continue;
if ( stat(buf, &st) != 0 )
continue;