summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
authorxebd <xeb@mail.ru>2020-10-21 12:43:25 +0300
committerGitHub <noreply@github.com>2020-10-21 12:43:25 +0300
commit45896ffa4e254cb5d6627602b72cd29abc477d7d (patch)
tree2a9bc2be6ccc6ee1a78d242d742e9633d6fa6d54 /accel-pppd
parente9d369aa0054312b7633e964e9f7eb323f1f3d69 (diff)
parent20e953572872308e0f139375bd32400729862611 (diff)
downloadaccel-ppp-45896ffa4e254cb5d6627602b72cd29abc477d7d.tar.gz
accel-ppp-45896ffa4e254cb5d6627602b72cd29abc477d7d.zip
Merge pull request #9 from shumbor/master
cli/telnet: fix crash on damaged history file.
Diffstat (limited to 'accel-pppd')
-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 33a82e47..4b5f63ba 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);