[sysdeps] Fix possible null-pointer dereference.

Message ID 20220401062521.514101-1-d.chestnyh@omp.ru
State New
Headers
Series [sysdeps] Fix possible null-pointer dereference. |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Dmitry Chestnyh April 1, 2022, 6:25 a.m. UTC
  Without suggested check we can have null-pointer
dereference at line 257.
---
 sysdeps/unix/sysv/linux/check_pf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Siddhesh Poyarekar June 13, 2022, 7:01 a.m. UTC | #1
On 01/04/2022 11:55, Dmitry Chestnyh wrote:
> Without suggested check we can have null-pointer
> dereference at line 257.

How so?  ISTM that for a valid message (which we rely on the kernel to 
provide) you're bound to have at least address or local (and 
consequently address) set at all times.

> ---
>   sysdeps/unix/sysv/linux/check_pf.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c
> index fe73fe3ba8..5d60e7ac2b 100644
> --- a/sysdeps/unix/sysv/linux/check_pf.c
> +++ b/sysdeps/unix/sysv/linux/check_pf.c
> @@ -237,7 +237,7 @@ make_request (int fd, pid_t pid)
>   				      * sizeof (struct in6addrinfo));
>   		}
>   
> -	      if (!result)
> +	      if (!result || !address)
>   		goto out_fail;
>   
>   	      struct in6addrinfo *info = &result->in6ai[result_len++];
  

Patch

diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c
index fe73fe3ba8..5d60e7ac2b 100644
--- a/sysdeps/unix/sysv/linux/check_pf.c
+++ b/sysdeps/unix/sysv/linux/check_pf.c
@@ -237,7 +237,7 @@  make_request (int fd, pid_t pid)
 				      * sizeof (struct in6addrinfo));
 		}
 
-	      if (!result)
+	      if (!result || !address)
 		goto out_fail;
 
 	      struct in6addrinfo *info = &result->in6ai[result_len++];