From: Linux Karlsson Date: Wed, 28 Jul 2010 16:18:55 +0000 (+0200) Subject: [Bug 1595] empty last line in key file causes duplicate key to be added X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=15249242403235c1b341798682776b321abd8388;p=thirdparty%2Fntp.git [Bug 1595] empty last line in key file causes duplicate key to be added bk: 4c50586fHW0OqK6iDqKAnnT5I-6G_w --- diff --git a/sntp/crypto.c b/sntp/crypto.c index ce47480915..c8fb85e7fc 100644 --- a/sntp/crypto.c +++ b/sntp/crypto.c @@ -114,7 +114,9 @@ auth_init( struct key *act = emalloc(sizeof(struct key)); int goodline = 0; - fgets(kbuf, sizeof(kbuf), keyf); + if (NULL == fgets(kbuf, sizeof(kbuf), keyf)) + continue; + kbuf[sizeof(kbuf) - 1] = '\0'; octothorpe = strchr(kbuf, '#'); if (octothorpe)