summaryrefslogtreecommitdiff
path: root/accel-pppd/cli
diff options
context:
space:
mode:
authorshumbor <55794505+shumbor@users.noreply.github.com>2020-10-15 15:29:01 +0300
committerGitHub <noreply@github.com>2020-10-15 15:29:01 +0300
commit20e953572872308e0f139375bd32400729862611 (patch)
treef2357a1fadb75d6c7a7c6421df2d446b42a5733c /accel-pppd/cli
parentc8575ff09416c967aa6907b5b4e9b187d4a78d14 (diff)
downloadaccel-ppp-xebd-20e953572872308e0f139375bd32400729862611.tar.gz
accel-ppp-xebd-20e953572872308e0f139375bd32400729862611.zip
cli/telnet: fix crash on damaged history file.
small check for zero buffer length on load history
Diffstat (limited to 'accel-pppd/cli')
-rw-r--r--accel-pppd/cli/telnet.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/accel-pppd/cli/telnet.c b/accel-pppd/cli/telnet.c
index 33a82e4..4b5f63b 100644
--- a/accel-pppd/cli/telnet.c
+++ b/accel-pppd/cli/telnet.c
@@ -732,11 +732,14 @@ static void load_history_file(void)
return;
while (fgets((char *)temp_buf, RECV_BUF_SIZE, f)) {
- b = _malloc(sizeof(*b) + strlen((char *)temp_buf) + 1);
- b->p_buf = NULL;
- b->size = strlen((char *)temp_buf) - 1;
- memcpy(b->buf, temp_buf, b->size);
- list_add_tail(&b->entry, &history);
+ int buf_len=strlen((char *)temp_buf);
+ if( buf_len > 0){
+ b = _malloc(sizeof(*b) + buf_len + 1);
+ b->p_buf = NULL;
+ b->size = buf_len - 1;
+ memcpy(b->buf, temp_buf, b->size);
+ list_add_tail(&b->entry, &history);
+ }
}
fclose(f);