]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1595] empty last line in key file causes duplicate key to be added
authorLinux Karlsson <karlsson@ntp.org>
Wed, 28 Jul 2010 16:18:55 +0000 (18:18 +0200)
committerLinux Karlsson <karlsson@ntp.org>
Wed, 28 Jul 2010 16:18:55 +0000 (18:18 +0200)
bk: 4c50586fHW0OqK6iDqKAnnT5I-6G_w

sntp/crypto.c

index ce47480915e06ebcdef364d276dbc6a2753e0202..c8fb85e7fc1c8d6b1ea64e1801cb905ab1f54003 100644 (file)
@@ -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)