diff --git a/src/collage.c b/src/collage.c index bcb30fae362e8a4ba992b013bc58fffb18bb7690..b975136a507d1ff279fca4862b3d94d8e89983c8 100644 --- a/src/collage.c +++ b/src/collage.c @@ -191,8 +191,10 @@ void init_collage_mode(void) char output_buf[1024]; if (opt.output_dir) snprintf(output_buf, 1024, "%s/%s", opt.output_dir, opt.output_file); - else - strncpy(output_buf, opt.output_file, 1024); + else { + strncpy(output_buf, opt.output_file, 1023); + output_buf[1023] = '\0'; + } gib_imlib_save_image(im_main, output_buf); if (opt.verbose) { int tw, th; diff --git a/src/index.c b/src/index.c index a71744df37f7aa8589abd3c9e838a159fb626fdd..7a2f5fc404ae55698f988752bc4bc30cf4e17f06 100644 --- a/src/index.c +++ b/src/index.c @@ -324,8 +324,10 @@ void init_index_mode(void) if (opt.output_dir) snprintf(output_buf, 1024, "%s/%s", opt.output_dir, opt.output_file); - else - strncpy(output_buf, opt.output_file, 1024); + else { + strncpy(output_buf, opt.output_file, 1023); + output_buf[1023] = '\0'; + } gib_imlib_save_image_with_error_return(im_main, output_buf, &err); if (err) { diff --git a/src/thumbnail.c b/src/thumbnail.c index c9cc24f8f097705b563de2da44257ee9e5c71694..43168c4c35c5be4366a2e7b635f4c8ccddf87f09 100644 --- a/src/thumbnail.c +++ b/src/thumbnail.c @@ -381,8 +381,10 @@ void init_thumbnail_mode(void) if (opt.output_dir) snprintf(output_buf, 1024, "%s/%s", opt.output_dir, opt.output_file); - else - strncpy(output_buf, opt.output_file, 1024); + else { + strncpy(output_buf, opt.output_file, 1023); + output_buf[1023] = '\0'; + } gib_imlib_save_image_with_error_return(td.im_main, output_buf, &err); if (err) { feh_imlib_print_load_error(output_buf, td.im_main, err);