#983743 group.c: use "snprintf()" instead of "sprintf()"

Package:
src:nn
Source:
nn
Submitter:
Bjarni Ingi Gislason
Date:
2021-03-01 01:00:04 UTC
Severity:
normal
Tags:
#983743#5
Date:
2021-03-01 00:56:50 UTC
From:
To:
Dear Maintainer,

  group.c: use "snprintf()" instead of "sprintf()".

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
---
 group.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/group.c b/group.c
index 2045e7b..8819d52 100644
--- a/group.c
+++ b/group.c
@@ -52,6 +52,7 @@ extern int      killed_articles;
 extern int      seq_cross_filtering;
 extern char    *default_save_file, *folder_save_file;

+extern const size_t NDELAYED_MSG;
 extern char     delayed_msg[];
 extern int32    db_read_counter;

@@ -541,7 +542,7 @@ goto_group(int command, article_header * ah, flag_type access_mode)
 	    goto_return(ME_NO_REDRAW);

 	if (gh->first_db_article < gh->last_db_article && gh->current_first <= 0) {
-	    sprintf(buffer, "%s%s%s) ",
+	    snprintf(buffer, FILENAME, "%s%s%s) ",
 		    (gh->group_flag & G_UNSUBSCRIBED) ? " UNSUB" : "",
 		    (gh->group_flag & G_MERGE_HEAD) ? " MERGED" : "",
 		    gh->unread_count <= 0 ? " READ" : "");
@@ -641,7 +642,7 @@ get_group_name:
 	    goto_return(ME_NO_REDRAW);
 	goto get_first;
     }
-    sprintf(buffer, "%c", ans1);
+    snprintf(buffer, FILENAME, "%c", ans1);

     switch (ans1) {

@@ -679,7 +680,7 @@ get_group_name:
 #endif

 		    *group_file_name = NUL;
-		    sprintf(fbuffer, "%s%ld", group_path_name, ah->a_number);
+		    snprintf(fbuffer, FILENAME, "%s%ld", group_path_name, ah->a_number);
 		    answer = fbuffer;
 		    goto get_folder;
 		}
@@ -1159,7 +1160,7 @@ merge_and_read(flag_type access_mode, char *mask)
     current_group = &dummy_group;

     kb = (kb + 1023) >> 10;
-    sprintf(delayed_msg, "Read %ld articles in %ld seconds (%ld kbyte/s)",
+    snprintf(delayed_msg, NDELAYED_MSG, "Read %ld articles in %ld seconds (%ld kbyte/s)",
 	    (long) db_read_counter, (long) t2, t2 > 0 ? kb / t2 : kb);

     menu(merged_header);