]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 3837] NULL pointer deref crash when ntpd deletes last interface.
authorDave Hart <hart@ntp.org>
Tue, 20 Jun 2023 18:41:45 +0000 (18:41 +0000)
committerDave Hart <hart@ntp.org>
Tue, 20 Jun 2023 18:41:45 +0000 (18:41 +0000)
           Correct UNLINK_EXPR_SLIST() when the list is empty.

bk: 6491f2e9h9dRK-n2x5FjCsRYlDjiZQ

ChangeLog
include/ntp_lists.h

index 93cdab8b94eb430d9e1cf091711f64b15317250a..a672f0522e10d26741f75a2b308213aebedf7633 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+---
+* [Bug 3837] NULL pointer deref crash when ntpd deletes last interface.
+             Reported by renmingshuai.  Correct UNLINK_EXPR_SLIST() when the
+             list is empty. <hart@ntp.org>
+
 ---
 (4.2.8p17) 2023/06/06 Released by Harlan Stenn <stenn@ntp.org>
 
index d741974943efa4a861cb3c0ddc5560720f79df0e..bed692ff294e669ba06a8156ccf15bccc0a6e5bf 100644 (file)
@@ -181,7 +181,7 @@ do {                                                                \
 
 #define UNLINK_EXPR_SLIST(punlinked, listhead, expr, nextlink, \
                          entrytype)                            \
-do {                                                           \
+if (NULL != (listhead)) {                                      \
        entrytype **ppentry;                                    \
                                                                \
        ppentry = &(listhead);                                  \
@@ -202,6 +202,8 @@ do {                                                                \
        } else {                                                \
                (punlinked) = NULL;                             \
        }                                                       \
+} else do {                                                    \
+       (punlinked) = NULL;                                     \
 } while (FALSE)
 
 #define UNLINK_SLIST(punlinked, listhead, ptounlink, nextlink, \