Message ID | 1514952123-26616-1-git-send-email-selva.nair@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [Openvpn-devel] Return NULL if GetAdaptersInfo fails | expand |
Hi, On 03-01-18 05:02, selva.nair@gmail.com wrote: > From: Selva Nair <selva.nair@gmail.com> > > - Currently a pointer to potentially uninitialized IP_ADAPTER_INFO > struct is returned on error causing ill-defined behaviour. > > Signed-off-by: Selva Nair <selva.nair@gmail.com> > --- > > There have been some reports of unexpected failure in GetAdaptersInfo. > When and why that happens is still unclear but this bug could explain > why the process goes into a tailspin in such occasions. > > src/openvpn/tun.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c > index 25831ce..6e16348 100644 > --- a/src/openvpn/tun.c > +++ b/src/openvpn/tun.c > @@ -4178,15 +4178,12 @@ get_adapter_info_list(struct gc_arena *gc) > else > { > pi = (PIP_ADAPTER_INFO) gc_malloc(size, false, gc); > - if ((status = GetAdaptersInfo(pi, &size)) == NO_ERROR) > - { > - return pi; > - } > - else > + if ((status = GetAdaptersInfo(pi, &size)) != NO_ERROR) > { > msg(M_INFO, "GetAdaptersInfo #2 failed (status=%u) : %s", > (unsigned int)status, > strerror_win32(status, gc)); > + pi = NULL; > } > } > return pi; > Less lines, *and* less bugs. Very good. Acked-by: Steffan Karger <steffan.karger@fox-it.com> -Steffan ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Hi, > -----Original Message----- > From: selva.nair@gmail.com [mailto:selva.nair@gmail.com] > Sent: Wednesday, January 03, 2018 5:02 AM > To: openvpn-devel@lists.sourceforge.net > Subject: [Openvpn-devel] [PATCH] Return NULL if GetAdaptersInfo fails > > From: Selva Nair <selva.nair@gmail.com> > > - Currently a pointer to potentially uninitialized IP_ADAPTER_INFO > struct is returned on error causing ill-defined behaviour. > > Signed-off-by: Selva Nair <selva.nair@gmail.com> > --- > > There have been some reports of unexpected failure in GetAdaptersInfo. > When and why that happens is still unclear but this bug could explain why the > process goes into a tailspin in such occasions. > > src/openvpn/tun.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 25831ce..6e16348 > 100644 > --- a/src/openvpn/tun.c > +++ b/src/openvpn/tun.c > @@ -4178,15 +4178,12 @@ get_adapter_info_list(struct gc_arena *gc) > else > { > pi = (PIP_ADAPTER_INFO) gc_malloc(size, false, gc); > - if ((status = GetAdaptersInfo(pi, &size)) == NO_ERROR) > - { > - return pi; > - } > - else > + if ((status = GetAdaptersInfo(pi, &size)) != NO_ERROR) > { > msg(M_INFO, "GetAdaptersInfo #2 failed (status=%u) : %s", > (unsigned int)status, > strerror_win32(status, gc)); > + pi = NULL; > } > } > return pi; > -- > 2.1.4 > > > ---------------------------------------------------------------------------- -- > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Openvpn-devel mailing list > Openvpn-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openvpn-devel I have reviewed the program flow after each get_adapter_info_list() function call. All code to use the return value of get_adapter_info_list() indeed checks the return value for non-NULL before using it. Acked-by: Simon Rozman <simon@rozman.si> Regards, Simon ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Thanks. Your patch has been applied to the master and release/2.4 branch. commit 5050c5b1ec3f2aa04140ab83f2498b3329381ee4 (master) commit d2b9bd80bab7ce56ada09b0df1c2baec8b029d93 (release/2.4) Author: Selva Nair Date: Tue Jan 2 23:02:03 2018 -0500 Return NULL if GetAdaptersInfo fails Signed-off-by: Selva Nair <selva.nair@gmail.com> Acked-by: Steffan Karger <steffan.karger@fox-it.com> Acked-by: Simon Rozman <simon@rozman.si> Message-Id: <1514952123-26616-1-git-send-email-selva.nair@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16139.html Signed-off-by: Gert Doering <gert@greenie.muc.de> -- kind regards, Gert Doering ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 25831ce..6e16348 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -4178,15 +4178,12 @@ get_adapter_info_list(struct gc_arena *gc) else { pi = (PIP_ADAPTER_INFO) gc_malloc(size, false, gc); - if ((status = GetAdaptersInfo(pi, &size)) == NO_ERROR) - { - return pi; - } - else + if ((status = GetAdaptersInfo(pi, &size)) != NO_ERROR) { msg(M_INFO, "GetAdaptersInfo #2 failed (status=%u) : %s", (unsigned int)status, strerror_win32(status, gc)); + pi = NULL; } } return pi;