diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2014-10-19 20:18:47 +0200 |
---|---|---|
committer | Pali Rohár <pali.rohar@gmail.com> | 2014-10-19 20:18:47 +0200 |
commit | 8d52950ede71561d1f266833f06e747b7d6e0768 (patch) | |
tree | 9bb7568f90fbab539f8a017d71432ca9ef19cc69 /src/main.c | |
parent | a8986bf631aff030483c695bfb1eed1584e73677 (diff) | |
download | 0xFFFF-8d52950ede71561d1f266833f06e747b7d6e0768.tar.bz2 |
main: Use snprintf instead sprintf and initialize buffer to NULL term
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1210,7 +1210,8 @@ int main(int argc, char **argv) { if ( ! image_tmp_name(i) ) continue; - sprintf(buf, "%hd", dev->detected_hwrev); + buf[0] = 0; + snprintf(buf, sizeof(buf), "%hd", dev->detected_hwrev); switch ( i ) { case IMAGE_2ND: @@ -1312,14 +1313,16 @@ int main(int argc, char **argv) { break; } - sprintf(buf, "%s-%s:%hd_%s", image_type_to_string(i), device_to_string(dev->detected_device), dev->detected_hwrev, ptr); + buf[0] = 0; + snprintf(buf, sizeof(buf), "%s-%s:%hd_%s", image_type_to_string(i), device_to_string(dev->detected_device), dev->detected_hwrev, ptr); printf("Renaming %s image file to %s...\n", image_type_to_string(i), buf); if ( rename(image_tmp_name(i), buf) < 0 ) { ERROR_INFO("Renaming failed"); - sprintf(buf, "%s-%s_%s", image_type_to_string(i), device_to_string(dev->detected_device), ptr); + buf[0] = 0; + snprintf(buf, sizeof(buf), "%s-%s_%s", image_type_to_string(i), device_to_string(dev->detected_device), ptr); printf("Trying to rename %s image file to %s...\n", image_type_to_string(i), buf); if ( rename(image_tmp_name(i), buf) < 0 ) |