From: Chris Allegretta Date: Wed, 12 Feb 2003 23:58:01 +0000 (+0000) Subject: - files.c: load_history() - Fix segfault on loading huge strings from history file... X-Git-Tag: v1.1.99pre3~13 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=a0449d92a08d76c5aa4492cd5ed1c6d8b42c252b;p=nano.git - files.c: load_history() - Fix segfault on loading huge strings from history file (David Benbennick) git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1455 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 3725cd21..e93f15c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,9 @@ CVS code intput_tab() - Fix assumption that matches is null terminated (David Benbennick). + load_history() + - Fix segfault on loading huge strings from history file + (David Benbennick). - nano.c: breakable() - Fix incorrect return value on short lines (David Benbennick). diff --git a/files.c b/files.c index 40c25a7a..9db26dee 100644 --- a/files.c +++ b/files.c @@ -2896,7 +2896,7 @@ void load_history(void) buf = charalloc(1024); while (fgets(buf, 1023, hist) != 0) { ptr = buf; - while (*ptr != '\n') + while (*ptr != '\n' && *ptr != '\0' && ptr < buf + 1023) ptr++; *ptr = '\0'; if (strlen(buf))