NetBSD-Bugs archive

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

Re: bin/51815: [PATCH] tests/lib/libc/string/t_str{chr,len}: don't leak dlopen'ed handle



The following reply was made to PR bin/51815; it has been noted by GNATS.

From: "Ngie Cooper (yaneurabeya)" <yaneurabeya%gmail.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: bin/51815: [PATCH] tests/lib/libc/string/t_str{chr,len}: don't
 leak dlopen'ed handle
Date: Tue, 10 Jan 2017 02:50:53 -0800

 --Apple-Mail=_3AA14E2C-4325-4B4E-BBB7-B9F81F10EA7D
 Content-Transfer-Encoding: 7bit
 Content-Type: text/plain;
 	charset=us-ascii
 
 Patch attached.
 
 --Apple-Mail=_3AA14E2C-4325-4B4E-BBB7-B9F81F10EA7D
 Content-Disposition: attachment;
 	filename=t_strchr-and-t_strlen-dont-leak-the-dlopen_ed-handle.patch
 Content-Type: application/octet-stream;
 	x-unix-mode=0644;
 	name="t_strchr-and-t_strlen-dont-leak-the-dlopen_ed-handle.patch"
 Content-Transfer-Encoding: 7bit
 
 Index: t_strchr.c
 ===================================================================
 RCS file: /cvsroot/src/tests/lib/libc/string/t_strchr.c,v
 retrieving revision 1.1
 diff -u -p -r1.1 t_strchr.c
 --- t_strchr.c	7 Jul 2011 08:59:33 -0000	1.1
 +++ t_strchr.c	10 Jan 2017 10:37:18 -0000
 @@ -58,9 +58,10 @@ ATF_TC_HEAD(strchr_basic, tc)
  
  ATF_TC_BODY(strchr_basic, tc)
  {
 -	unsigned int t, a;
 +	void *dl_handle;
  	char *off;
  	char buf[32];
 +	unsigned int t, a;
  
  	const char *tab[] = {
  		"",
 @@ -245,8 +246,8 @@ ATF_TC_BODY(strchr_basic, tc)
  		"abcdefgh/abcdefgh/",
  	};
  
 -
 -	strchr_fn = dlsym(dlopen(0, RTLD_LAZY), "test_strchr");
 +	dl_handle = dlopen(NULL, RTLD_LAZY);
 +	strchr_fn = dlsym(dl_handle, "test_strlen");
  	if (!strchr_fn)
  		strchr_fn = strchr;
  
 @@ -281,6 +282,7 @@ ATF_TC_BODY(strchr_basic, tc)
  			verify_strchr(buf + a, 0xff, t, a);
  		}
  	}
 +	(void)dlclose(dl_handle);
  }
  
  ATF_TP_ADD_TCS(tp)
 
 --Apple-Mail=_3AA14E2C-4325-4B4E-BBB7-B9F81F10EA7D--
 


Home | Main Index | Thread Index | Old Index