]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
fix heap-buffer-overflow issue in function cfg_mark_ports of file util/config_file.c 1040/head
authorzhailiangliang <zhailiangliang@loongson.cn>
Wed, 3 Apr 2024 07:40:58 +0000 (15:40 +0800)
committerzhailiangliang <zhailiangliang@loongson.cn>
Wed, 3 Apr 2024 07:40:58 +0000 (15:40 +0800)
util/config_file.c

index 26185da0203cef408a9908ac6adf12de57ef6c12..e7b2f1959f3637236f50b5a34a6ece99993d6c2b 100644 (file)
@@ -1761,6 +1761,10 @@ cfg_mark_ports(const char* str, int allow, int* avail, int num)
 #endif
        if(!mid) {
                int port = atoi(str);
+               if(port < 0) {
+                       log_err("Prevent out-of-bounds access to array avail");
+                       return 0;
+               }
                if(port == 0 && strcmp(str, "0") != 0) {
                        log_err("cannot parse port number '%s'", str);
                        return 0;