From 62c116200c2c8c40752f65ab2bdca119b1bd1b0c Mon Sep 17 00:00:00 2001 From: ubuntu201711081 <201711081@jbnu.ac.kr> Date: Sat, 5 Dec 2020 02:21:10 +0000 Subject: [PATCH] fix invalid str --- client.c | 3 ++- p-client.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client.c b/client.c index 63e2ad6..47d03f5 100644 --- a/client.c +++ b/client.c @@ -75,10 +75,11 @@ void DisplayProgressBar(size_t offset,size_t total,double cur_progress){ } void DisplayProgressBar100Percent(size_t total){ size_t i; - char buf[PROGRESS_BAR_WIDTH]; + char buf[PROGRESS_BAR_WIDTH+1]; for (i = 0; i < PROGRESS_BAR_WIDTH; i++){ buf[i] = '='; } + buf[PROGRESS_BAR_WIDTH] = '\0'; printf("\r[%s]: 100%% bytes: %ld/%ld bytes\n",buf,total,total); } int recvFile(int sock, const char * filename,size_t file_size){ diff --git a/p-client.c b/p-client.c index ee26707..d36f3e6 100644 --- a/p-client.c +++ b/p-client.c @@ -76,10 +76,11 @@ void DisplayProgressBar(size_t offset,size_t total,double cur_progress){ } void DisplayProgressBar100Percent(size_t total){ size_t i; - char buf[PROGRESS_BAR_WIDTH]; + char buf[PROGRESS_BAR_WIDTH+1]; for (i = 0; i < PROGRESS_BAR_WIDTH; i++){ buf[i] = '='; } + buf[PROGRESS_BAR_WIDTH] = '\0'; printf("\r[%s]: 100%% bytes: %ld/%ld bytes\n",buf,total,total); } int recvFile(int sock, const char * filename,size_t file_size){