fix heap-buffer-overflow issue in function cfg_mark_ports of file util/config_file.c

This commit is contained in:
zhailiangliang 2024-04-03 15:40:58 +08:00
parent e1aeabde44
commit 193401e754

View 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;