From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([69.77.167.62] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1LTK76-0004ND-Ja for garchives@archives.gentoo.org; Sat, 31 Jan 2009 17:58:40 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E50FBE02E6; Sat, 31 Jan 2009 17:58:38 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id A2267E02E6 for ; Sat, 31 Jan 2009 17:58:38 +0000 (UTC) Received: from stork.gentoo.org (stork.gentoo.org [64.127.104.133]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTP id 468306435F for ; Sat, 31 Jan 2009 17:58:38 +0000 (UTC) Received: from grobian by stork.gentoo.org with local (Exim 4.69) (envelope-from ) id 1LTK73-0007yT-Tr for gentoo-commits@lists.gentoo.org; Sat, 31 Jan 2009 17:58:37 +0000 From: "Fabian Groffen (grobian)" To: gentoo-commits@lists.gentoo.org Reply-To: gentoo-dev@lists.gentoo.org, grobian@gentoo.org Subject: [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c xfuncs.c xfuncs.h X-VCS-Repository: gentoo-projects X-VCS-Files: scanelf.c xfuncs.c xfuncs.h X-VCS-Directories: pax-utils X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen Content-Type: text/plain; charset=utf8 Message-Id: Sender: Fabian Groffen Date: Sat, 31 Jan 2009 17:58:37 +0000 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 849664a9-9e8e-4863-8438-ba4270651ea8 X-Archives-Hash: 88a4e624194375c6a44cf5771bda02a1 grobian 09/01/31 17:58:37 Modified: scanelf.c xfuncs.c xfuncs.h Log: For bug #249731, add an xstrndup wrapper, and implement strndup on host= s that don't have it, based on the strndup implementation of sandbox, wit= h a little change to make it C90 compliant. Revision Changes Path 1.208 pax-utils/scanelf.c file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/sca= nelf.c?rev=3D1.208&view=3Dmarkup plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/sca= nelf.c?rev=3D1.208&content-type=3Dtext/plain diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/sca= nelf.c?r1=3D1.207&r2=3D1.208 Index: scanelf.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v retrieving revision 1.207 retrieving revision 1.208 diff -u -r1.207 -r1.208 --- scanelf.c 30 Dec 2008 13:38:35 -0000 1.207 +++ scanelf.c 31 Jan 2009 17:58:37 -0000 1.208 @@ -1,13 +1,13 @@ /* * Copyright 2003-2007 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.207 200= 8/12/30 13:38:35 vapier Exp $ + * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.208 200= 9/01/31 17:58:37 grobian Exp $ * * Copyright 2003-2007 Ned Ludd - * Copyright 2004-2007 Mike Frysinger - */ =20 -static const char *rcsid =3D "$Id: scanelf.c,v 1.207 2008/12/30 13:38:35= vapier Exp $"; +static const char *rcsid =3D "$Id: scanelf.c,v 1.208 2009/01/31 17:58:37= grobian Exp $"; const char * const argv0 =3D "scanelf"; =20 #include "paxinc.h" @@ -1038,7 +1038,7 @@ ++this_sym; \ } \ if (next_sym) /* Copy it so that we don't have to worry about the = final , */ \ - this_sym =3D strndup(this_sym, next_sym-this_sym); \ + this_sym =3D xstrndup(this_sym, next_sym-this_sym); \ /* ok, lets compare the name now */ \ if (scanelf_match_symname(this_sym, symname)) { \ if (be_semi_verbose) { \ 1.4 pax-utils/xfuncs.c file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/xfu= ncs.c?rev=3D1.4&view=3Dmarkup plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/xfu= ncs.c?rev=3D1.4&content-type=3Dtext/plain diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/xfu= ncs.c?r1=3D1.3&r2=3D1.4 Index: xfuncs.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /var/cvsroot/gentoo-projects/pax-utils/xfuncs.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- xfuncs.c 30 Dec 2008 13:00:29 -0000 1.3 +++ xfuncs.c 31 Jan 2009 17:58:37 -0000 1.4 @@ -1,7 +1,7 @@ /* * Copyright 2003-2007 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/pax-utils/xfuncs.c,v 1.3 2008/1= 2/30 13:00:29 vapier Exp $ + * $Header: /var/cvsroot/gentoo-projects/pax-utils/xfuncs.c,v 1.4 2009/0= 1/31 17:58:37 grobian Exp $ * * Copyright 2003-2007 Ned Ludd - * Copyright 2004-2007 Mike Frysinger - @@ -16,6 +16,32 @@ return ret; } =20 +#ifndef strndup +static inline char *my_strndup(const char *str, size_t n) +{ + size_t r; + char *ret; + for (r =3D 0; r < n; ++r) + if (!str[r]) + break; + + ret =3D xmalloc(r + 1); + memcpy(ret, str, r); + ret[r] =3D '\0'; + return ret; +} +/* do this to avoid warning: declaration of 'strndup' shadows a built-in + * function */ +#define strndup(S, N) my_strndup(S, N) +#endif + +char *xstrndup(const char *s, const size_t n) +{ + char *ret =3D strndup(s, n); + if (!ret) err("Could not strdup(): %s", strerror(errno)); + return ret; +} + void *xmalloc(size_t size) { void *ret =3D malloc(size); 1.3 pax-utils/xfuncs.h file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/xfu= ncs.h?rev=3D1.3&view=3Dmarkup plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/xfu= ncs.h?rev=3D1.3&content-type=3Dtext/plain diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/xfu= ncs.h?r1=3D1.2&r2=3D1.3 Index: xfuncs.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /var/cvsroot/gentoo-projects/pax-utils/xfuncs.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- xfuncs.h 30 Dec 2008 12:58:08 -0000 1.2 +++ xfuncs.h 31 Jan 2009 17:58:37 -0000 1.3 @@ -1,7 +1,7 @@ /* * Copyright 2003-2007 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/pax-utils/xfuncs.h,v 1.2 2008/1= 2/30 12:58:08 vapier Exp $ + * $Header: /var/cvsroot/gentoo-projects/pax-utils/xfuncs.h,v 1.3 2009/0= 1/31 17:58:37 grobian Exp $ * * Copyright 2003-2007 Ned Ludd - * Copyright 2004-2007 Mike Frysinger - @@ -11,6 +11,7 @@ #define __XFUNCS_H__ =20 char *xstrdup(const char *s); +char *xstrndup(const char *s, const size_t n); void *xmalloc(size_t size); void *xzalloc(size_t size); void *xrealloc(void *ptr, size_t size);