wget-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wget2 | Draft: CIDR support added for No Proxy. Testing Code Added (


From: @rockdaboot
Subject: Re: wget2 | Draft: CIDR support added for No Proxy. Testing Code Added (!521)
Date: Mon, 10 Apr 2023 09:49:43 +0000



Tim Rühsen started a new discussion on libwget/http.c: 
https://gitlab.com/gnuwget/wget2/-/merge_requests/521#note_1346547084

> +}
> +
> +static bool wget_http_cidr_match(const char *cidr, struct in_addr *addr)
> +{
> +     const char *slash_pos = strchr(cidr, '/');
> +     if (slash_pos == NULL) {
> +             return false; // invalid CIDR range
> +     }
> +     int prefix_len = atoi(slash_pos + 1);
> +     if (prefix_len < 0 || prefix_len > 32) {
> +             return false; // invalid prefix length
> +     }
> +     struct in_addr network_addr;
> +     const char *prefix = wget_strmemdup(cidr, slash_pos - cidr);
> +     if (inet_aton(prefix, &network_addr) != 1) {
> +             wget_free((void *)prefix);

We have a macro around `wget_free`, `xfree()`. It does the `(void *)` cast for 
you and sets the argument to NULL to prevent use-after-free errors.

-- 
Reply to this email directly or view it on GitLab: 
https://gitlab.com/gnuwget/wget2/-/merge_requests/521#note_1346547084
You're receiving this email because of your account on gitlab.com.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]