--- asterisk.c 31 Jul 2004 20:25:07 -0000 1.110 +++ asterisk.c 31 Jul 2004 23:23:00 -0000 @@ -1297,11 +1315,19 @@ static int ast_el_add_history(char *buf) { HistEvent ev; + int len = strlen(buf); if (el_hist == NULL || el == NULL) ast_el_initialize(); - if (strlen(buf) > 256) + + while (len-- > 0) { + if (!isspace(buf[len])) + break; + buf[len] = '\0'; + } + if (len < 1 || len > 256) return 0; + return (history(el_hist, &ev, H_ENTER, buf)); } @@ -1328,7 +1354,8 @@ return ret; while (!feof(f)) { - fgets(buf, sizeof(buf), f); + if (fgets(buf, sizeof(buf), f) == NULL) + break; if (!strcmp(buf, "_HiStOrY_V2_\n")) continue; if ((ret = ast_el_add_history(buf)) == -1)