summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2014-10-19 20:18:47 +0200
committerPali Rohár <pali.rohar@gmail.com>2014-10-19 20:18:47 +0200
commit8d52950ede71561d1f266833f06e747b7d6e0768 (patch)
tree9bb7568f90fbab539f8a017d71432ca9ef19cc69 /src/main.c
parenta8986bf631aff030483c695bfb1eed1584e73677 (diff)
download0xFFFF-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.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 041299d..ff99dc3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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 )