public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2008-09-29  6:01 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2008-09-29  6:01 UTC (permalink / raw
  To: gentoo-commits

vapier      08/09/29 06:01:22

  Modified:             scanelf.c
  Log:
  only issue warnings on missing cache code when targeting an ELF system

Revision  Changes    Path
1.192                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.192&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.192&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.191&r2=1.192

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.191
retrieving revision 1.192
diff -u -r1.191 -r1.192
--- scanelf.c	17 Jun 2008 17:07:57 -0000	1.191
+++ scanelf.c	29 Sep 2008 06:01:22 -0000	1.192
@@ -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.191 2008/06/17 17:07:57 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.192 2008/09/29 06:01:22 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.191 2008/06/17 17:07:57 solar Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.192 2008/09/29 06:01:22 vapier Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -796,7 +796,9 @@
 	return NULL;
 }
 #else
+#ifdef __ELF__
 #warning Cache support not implemented for your target
+#endif
 static char *lookup_cache_lib(elfobj *elf, char *fname)
 {
 	return NULL;
@@ -1546,13 +1548,14 @@
 }
 
 #else
-
+#ifdef __ELF__
 #warning Cache config support not implemented for your target
+#endif
 static int load_ld_cache_config(int i, const char *fname)
 {
 	memset(ldpaths, 0x00, sizeof(ldpaths));
+	return 0;
 }
-
 #endif
 
 /* scan /etc/ld.so.conf for paths */






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2008-09-29  6:03 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2008-09-29  6:03 UTC (permalink / raw
  To: gentoo-commits

vapier      08/09/29 06:03:27

  Modified:             scanelf.c
  Log:
  add a cast to off_t printf to silence warning #236464

Revision  Changes    Path
1.193                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.193&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.193&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.192&r2=1.193

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.192
retrieving revision 1.193
diff -u -r1.192 -r1.193
--- scanelf.c	29 Sep 2008 06:01:22 -0000	1.192
+++ scanelf.c	29 Sep 2008 06:03:26 -0000	1.193
@@ -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.192 2008/09/29 06:01:22 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.193 2008/09/29 06:03:26 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.192 2008/09/29 06:01:22 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.193 2008/09/29 06:03:26 vapier Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -1234,7 +1234,7 @@
 		case 'a': out = get_elfemtype(elf); break;
 		case 'I': out = get_elfosabi(elf); break;
 		case 'Y': out = get_elf_eabi(elf); break;
-		case 'Z': snprintf(ubuf, sizeof(ubuf), "%lu", elf->len); out = ubuf; break;;
+		case 'Z': snprintf(ubuf, sizeof(ubuf), "%lu", (unsigned long)elf->len); out = ubuf; break;;
 		default: warnf("'%c' has no scan code?", out_format[i]);
 		}
 		if (out) {






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2008-09-29  6:05 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2008-09-29  6:05 UTC (permalink / raw
  To: gentoo-commits

vapier      08/09/29 06:05:56

  Modified:             scanelf.c
  Log:
  fix by Fabian Groffen to make sure default output format starts off initialized before we start strcating it #236539

Revision  Changes    Path
1.194                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.194&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.194&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.193&r2=1.194

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.193
retrieving revision 1.194
diff -u -r1.193 -r1.194
--- scanelf.c	29 Sep 2008 06:03:26 -0000	1.193
+++ scanelf.c	29 Sep 2008 06:05:55 -0000	1.194
@@ -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.193 2008/09/29 06:03:26 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.194 2008/09/29 06:05:55 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.193 2008/09/29 06:03:26 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.194 2008/09/29 06:05:55 vapier Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -1906,6 +1906,7 @@
 	} else {
 		size_t fmt_len = 30;
 		out_format = xmalloc(sizeof(char) * fmt_len);
+		*out_format = '\0';
 		if (!be_quiet)     xstrcat(&out_format, "%o ", &fmt_len);
 		if (show_pax)      xstrcat(&out_format, "%x ", &fmt_len);
 		if (show_perms)    xstrcat(&out_format, "%O ", &fmt_len);






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2008-10-22 15:20 Diego Petteno (flameeyes)
  0 siblings, 0 replies; 62+ messages in thread
From: Diego Petteno (flameeyes) @ 2008-10-22 15:20 UTC (permalink / raw
  To: gentoo-commits

flameeyes    08/10/22 15:20:21

  Modified:             scanelf.c
  Log:
  Avoid crashes when scanning files with "corrupt symbols".
  
  Instead of dereferencing sym without checking, stop as soon as the
  pointer goes out of the ELF file range.

Revision  Changes    Path
1.195                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.195&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.195&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.194&r2=1.195

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.194
retrieving revision 1.195
diff -u -r1.194 -r1.195
--- scanelf.c	29 Sep 2008 06:05:55 -0000	1.194
+++ scanelf.c	22 Oct 2008 15:20:21 -0000	1.195
@@ -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.194 2008/09/29 06:05:55 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.195 2008/10/22 15:20:21 flameeyes Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.194 2008/09/29 06:05:55 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.195 2008/10/22 15:20:21 flameeyes Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -999,6 +999,10 @@
 		if (cnt) \
 			cnt = EGET(symtab->sh_size) / cnt; \
 		for (i = 0; i < cnt; ++i) { \
+			if ( (void*)sym > (void*)elf->data_end ) { \
+				warnf("%s: corrupt ELF symbols - aborting", elf->filename); \
+				goto break_out;	\
+			} \
 			if (sym->st_name) { \
 				/* make sure the symbol name is in acceptable memory range */ \
 				symname = (char *)(elf->data + EGET(strtab->sh_offset) + EGET(sym->st_name)); \






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2008-10-22 17:03 Diego Petteno (flameeyes)
  0 siblings, 0 replies; 62+ messages in thread
From: Diego Petteno (flameeyes) @ 2008-10-22 17:03 UTC (permalink / raw
  To: gentoo-commits

flameeyes    08/10/22 17:03:17

  Modified:             scanelf.c
  Log:
  Fixing whitespace.

Revision  Changes    Path
1.196                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.196&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.196&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.195&r2=1.196

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.195
retrieving revision 1.196
diff -u -r1.195 -r1.196
--- scanelf.c	22 Oct 2008 15:20:21 -0000	1.195
+++ scanelf.c	22 Oct 2008 17:03:17 -0000	1.196
@@ -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.195 2008/10/22 15:20:21 flameeyes Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.196 2008/10/22 17:03:17 flameeyes Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.195 2008/10/22 15:20:21 flameeyes Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.196 2008/10/22 17:03:17 flameeyes Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -999,7 +999,7 @@
 		if (cnt) \
 			cnt = EGET(symtab->sh_size) / cnt; \
 		for (i = 0; i < cnt; ++i) { \
-			if ( (void*)sym > (void*)elf->data_end ) { \
+			if ((void*)sym > (void*)elf->data_end) { \
 				warnf("%s: corrupt ELF symbols - aborting", elf->filename); \
 				goto break_out;	\
 			} \






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2008-11-17 18:03 Diego Petteno (flameeyes)
  0 siblings, 0 replies; 62+ messages in thread
From: Diego Petteno (flameeyes) @ 2008-11-17 18:03 UTC (permalink / raw
  To: gentoo-commits

flameeyes    08/11/17 18:03:38

  Modified:             scanelf.c
  Log:
  Rewrite symbol matching code in scanelf.
  
  The previous code was entirely broken when trying to match symbols in
  unstripped binaries when giving multiple symbols as target.
  
  The new code differs from the old one in quite a few ways:
  
  - debug output when -g option is passed is disabled in the code
    (hacky, but still better than before!);
  
  - regular expression matching is actually used when -g option is
    passed;
  
  - by default, the symbol name is tested against the symbol name
    without version; no-version symbol name matching is possible by
    using the -g option and adding a final $;
  
  - multiple symbols and single symbols are handled in the same way so
    that there is no more difference between them;
  
  - the returned symbol name is the actual symbol name as found in the
    file, so includes the version when the file is not stripped.
  
  While this means that there are some minimal differences between the
  previous code, it's arguable that this code is less buggy and more
  consistent than the one before.

Revision  Changes    Path
1.197                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.197&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.197&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.196&r2=1.197

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.196
retrieving revision 1.197
diff -u -r1.196 -r1.197
--- scanelf.c	22 Oct 2008 17:03:17 -0000	1.196
+++ scanelf.c	17 Nov 2008 18:03:38 -0000	1.197
@@ -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.196 2008/10/22 17:03:17 flameeyes Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.197 2008/11/17 18:03:38 flameeyes Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.196 2008/10/22 17:03:17 flameeyes Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.197 2008/11/17 18:03:38 flameeyes Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -977,6 +977,22 @@
 	return NULL;
 }
 
+static int scanelf_match_symname(const char *compare, const char *symname, const char *symname_ver) {
+	/* We do things differently when checking with regexp */
+	if (g_match) {
+		return rematch(symname, compare, REG_EXTENDED) == 0 ||
+			rematch(symname_ver, compare, REG_EXTENDED) == 0;
+	} else {
+		const size_t symname_len = strlen(symname);
+		if (strncmp(symname, compare, symname_len) == 0 &&
+		     /* Accept unversioned symbol names */
+		     (compare[symname_len] == '\0' || compare[symname_len] == '@'))
+			return 1;
+
+		return strcmp(symname_ver, symname) == 0;
+	}
+}
+
 static char *scanelf_file_sym(elfobj *elf, char *found_sym)
 {
 	unsigned long i;
@@ -1012,7 +1028,7 @@
 					continue; \
 				} \
 				/* debug display ... show all symbols and some extra info */ \
-				if (g_match ? rematch(ret, symname, REG_EXTENDED) == 0 : *ret == '*') { \
+				if (0 && g_match ? rematch(ret, symname, REG_EXTENDED) == 0 : *ret == '*') { \
 					printf("%s(%s) %5lX %15s %s %s\n", \
 					       ((*found_sym == 0) ? "\n\t" : "\t"), \
 					       elf->base_filename, \
@@ -1023,40 +1039,41 @@
 				} else { \
 					/* allow the user to specify a comma delimited list of symbols to search for */ \
 					char *this_sym, *this_sym_ver, *next_sym; \
-					this_sym = ret; \
+					next_sym = ret; \
 					this_sym_ver = versioned_symname; \
-					do { \
-						next_sym = strchr(this_sym, ','); \
-						if (next_sym == NULL) \
-							next_sym = this_sym + strlen(this_sym); \
+					while (next_sym) { \
+						this_sym = next_sym; \
+						if ((next_sym = strchr(this_sym, ','))) \
+							next_sym += 1; /* Skip the comma */ \
 						/* do we want a defined symbol ? */ \
 						if (*this_sym == '+') { \
 							if (sym->st_shndx == SHN_UNDEF) \
-								goto skip_this_sym##B; \
+								continue; \
 							++this_sym; \
 							++this_sym_ver; \
 						/* do we want an undefined symbol ? */ \
 						} else if (*this_sym == '-') { \
 							if (sym->st_shndx != SHN_UNDEF) \
-								goto skip_this_sym##B; \
+								continue; \
 							++this_sym; \
 							++this_sym_ver; \
 						} \
+						if (next_sym) /* Copy it so that we don't have to worry about the final , */ \
+							this_sym = strndup(this_sym, next_sym-this_sym); \
 						/* ok, lets compare the name now */ \
-						if ((strncmp(this_sym, symname, (next_sym-this_sym)) == 0 && symname[next_sym-this_sym] == '\0') || \
-						    (strncmp(this_sym_ver, symname, strlen(this_sym_ver)) == 0)) { \
+						if (scanelf_match_symname(symname, this_sym, this_sym_ver)) { \
 							if (be_semi_verbose) { \
 								char buf[126]; \
 								snprintf(buf, sizeof(buf), "%lX %s %s", \
 									(unsigned long)sym->st_size, get_elfstttype(sym->st_info), this_sym); \
 								ret = buf; \
 							} else \
-								ret = this_sym; \
+								ret = symname; \
 							(*found_sym)++; \
 							goto break_out; \
 						} \
-						skip_this_sym##B: this_sym = next_sym + 1; \
-					} while (*next_sym != '\0'); \
+						if (next_sym) free(this_sym); \
+					} \
 				} \
 			} \
 			++sym; \






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2008-11-17 18:09 Diego Petteno (flameeyes)
  0 siblings, 0 replies; 62+ messages in thread
From: Diego Petteno (flameeyes) @ 2008-11-17 18:09 UTC (permalink / raw
  To: gentoo-commits

flameeyes    08/11/17 18:09:55

  Modified:             scanelf.c
  Log:
  Remove the half-assed versioned_symname support.
  
  Matching against versioned symbol is possible (when the file is not
  stripped, for now) by using the regular expression matching (-g).

Revision  Changes    Path
1.198                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.198&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.198&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.197&r2=1.198

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.197
retrieving revision 1.198
diff -u -r1.197 -r1.198
--- scanelf.c	17 Nov 2008 18:03:38 -0000	1.197
+++ scanelf.c	17 Nov 2008 18:09:55 -0000	1.198
@@ -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.197 2008/11/17 18:03:38 flameeyes Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.198 2008/11/17 18:09:55 flameeyes Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.197 2008/11/17 18:03:38 flameeyes Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.198 2008/11/17 18:09:55 flameeyes Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -57,7 +57,7 @@
 static char be_verbose = 0;
 static char be_wewy_wewy_quiet = 0;
 static char be_semi_verbose = 0;
-static char *find_sym = NULL, *versioned_symname = NULL;
+static char *find_sym = NULL;
 static char *find_lib = NULL;
 static char *find_section = NULL;
 static char *out_format = NULL;
@@ -977,19 +977,15 @@
 	return NULL;
 }
 
-static int scanelf_match_symname(const char *compare, const char *symname, const char *symname_ver) {
+static int scanelf_match_symname(const char *symname, const char *tomatch) {
 	/* We do things differently when checking with regexp */
 	if (g_match) {
-		return rematch(symname, compare, REG_EXTENDED) == 0 ||
-			rematch(symname_ver, compare, REG_EXTENDED) == 0;
+		return rematch(symname, tomatch, REG_EXTENDED) == 0;
 	} else {
 		const size_t symname_len = strlen(symname);
-		if (strncmp(symname, compare, symname_len) == 0 &&
-		     /* Accept unversioned symbol names */
-		     (compare[symname_len] == '\0' || compare[symname_len] == '@'))
-			return 1;
-
-		return strcmp(symname_ver, symname) == 0;
+		return (strncmp(symname, tomatch, symname_len) == 0 &&
+			/* Accept unversioned symbol names */
+			(tomatch[symname_len] == '\0' || tomatch[symname_len] == '@'));
 	}
 }
 
@@ -1038,9 +1034,8 @@
 					*found_sym = 1; \
 				} else { \
 					/* allow the user to specify a comma delimited list of symbols to search for */ \
-					char *this_sym, *this_sym_ver, *next_sym; \
+					char *this_sym, *next_sym; \
 					next_sym = ret; \
-					this_sym_ver = versioned_symname; \
 					while (next_sym) { \
 						this_sym = next_sym; \
 						if ((next_sym = strchr(this_sym, ','))) \
@@ -1050,18 +1045,16 @@
 							if (sym->st_shndx == SHN_UNDEF) \
 								continue; \
 							++this_sym; \
-							++this_sym_ver; \
 						/* do we want an undefined symbol ? */ \
 						} else if (*this_sym == '-') { \
 							if (sym->st_shndx != SHN_UNDEF) \
 								continue; \
 							++this_sym; \
-							++this_sym_ver; \
 						} \
 						if (next_sym) /* Copy it so that we don't have to worry about the final , */ \
 							this_sym = strndup(this_sym, next_sym-this_sym); \
 						/* ok, lets compare the name now */ \
-						if (scanelf_match_symname(symname, this_sym, this_sym_ver)) { \
+						if (scanelf_match_symname(this_sym, symname)) { \
 							if (be_semi_verbose) { \
 								char buf[126]; \
 								snprintf(buf, sizeof(buf), "%lX %s %s", \
@@ -1785,8 +1778,6 @@
 		case 's': {
 			if (find_sym) warn("You prob don't want to specify -s twice");
 			find_sym = optarg;
-			versioned_symname = xmalloc(sizeof(char) * (strlen(find_sym)+1+1));
-			sprintf(versioned_symname, "%s@", find_sym);
 			break;
 		}
 		case 'N': {
@@ -1969,7 +1960,6 @@
 	}
 
 	/* clean up */
-	free(versioned_symname);
 	for (i = 0; ldpaths[i]; ++i)
 		free(ldpaths[i]);
 






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2008-12-10 20:05 Fabian Groffen (grobian)
  0 siblings, 0 replies; 62+ messages in thread
From: Fabian Groffen (grobian) @ 2008-12-10 20:05 UTC (permalink / raw
  To: gentoo-commits

grobian     08/12/10 20:05:20

  Modified:             scanelf.c
  Log:
  Fix manpage, thanks pipping

Revision  Changes    Path
1.199                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.199&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.199&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.198&r2=1.199

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.198
retrieving revision 1.199
diff -u -r1.198 -r1.199
--- scanelf.c	17 Nov 2008 18:09:55 -0000	1.198
+++ scanelf.c	10 Dec 2008 20:05:20 -0000	1.199
@@ -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.198 2008/11/17 18:09:55 flameeyes Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.199 2008/12/10 20:05:20 grobian Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.198 2008/11/17 18:09:55 flameeyes Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.199 2008/12/10 20:05:20 grobian Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -1039,7 +1039,7 @@
 					while (next_sym) { \
 						this_sym = next_sym; \
 						if ((next_sym = strchr(this_sym, ','))) \
-							next_sym += 1; /* Skip the comma */ \
+							*next_sym++ = '\0'; /* Skip the comma */ \
 						/* do we want a defined symbol ? */ \
 						if (*this_sym == '+') { \
 							if (sym->st_shndx == SHN_UNDEF) \
@@ -1051,8 +1051,6 @@
 								continue; \
 							++this_sym; \
 						} \
-						if (next_sym) /* Copy it so that we don't have to worry about the final , */ \
-							this_sym = strndup(this_sym, next_sym-this_sym); \
 						/* ok, lets compare the name now */ \
 						if (scanelf_match_symname(this_sym, symname)) { \
 							if (be_semi_verbose) { \
@@ -1065,7 +1063,6 @@
 							(*found_sym)++; \
 							goto break_out; \
 						} \
-						if (next_sym) free(this_sym); \
 					} \
 				} \
 			} \






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2008-12-10 20:06 Fabian Groffen (grobian)
  0 siblings, 0 replies; 62+ messages in thread
From: Fabian Groffen (grobian) @ 2008-12-10 20:06 UTC (permalink / raw
  To: gentoo-commits

grobian     08/12/10 20:06:20

  Modified:             scanelf.c
  Log:
  undo accidential 'fix'

Revision  Changes    Path
1.200                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.200&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.200&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.199&r2=1.200

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.199
retrieving revision 1.200
diff -u -r1.199 -r1.200
--- scanelf.c	10 Dec 2008 20:05:20 -0000	1.199
+++ scanelf.c	10 Dec 2008 20:06:20 -0000	1.200
@@ -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.199 2008/12/10 20:05:20 grobian Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.200 2008/12/10 20:06:20 grobian Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.199 2008/12/10 20:05:20 grobian Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.200 2008/12/10 20:06:20 grobian Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -1039,7 +1039,7 @@
 					while (next_sym) { \
 						this_sym = next_sym; \
 						if ((next_sym = strchr(this_sym, ','))) \
-							*next_sym++ = '\0'; /* Skip the comma */ \
+							next_sym += 1; /* Skip the comma */ \
 						/* do we want a defined symbol ? */ \
 						if (*this_sym == '+') { \
 							if (sym->st_shndx == SHN_UNDEF) \
@@ -1051,6 +1051,8 @@
 								continue; \
 							++this_sym; \
 						} \
+						if (next_sym) /* Copy it so that we don't have to worry about the final , */ \
+							this_sym = strndup(this_sym, next_sym-this_sym); \
 						/* ok, lets compare the name now */ \
 						if (scanelf_match_symname(this_sym, symname)) { \
 							if (be_semi_verbose) { \
@@ -1063,6 +1065,7 @@
 							(*found_sym)++; \
 							goto break_out; \
 						} \
+						if (next_sym) free(this_sym); \
 					} \
 				} \
 			} \






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2008-12-30 12:38 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2008-12-30 12:38 UTC (permalink / raw
  To: gentoo-commits

vapier      08/12/30 12:38:04

  Modified:             scanelf.c
  Log:
  use MAP_FAILED rather than custom constant

Revision  Changes    Path
1.202                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.202&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.202&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.201&r2=1.202

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.201
retrieving revision 1.202
diff -u -r1.201 -r1.202
--- scanelf.c	30 Dec 2008 12:00:06 -0000	1.201
+++ scanelf.c	30 Dec 2008 12:38:04 -0000	1.202
@@ -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.201 2008/12/30 12:00:06 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.202 2008/12/30 12:38:04 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.201 2008/12/30 12:00:06 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.202 2008/12/30 12:38:04 vapier Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -740,7 +740,7 @@
 
 		close(fd);
 
-		if (ldcache == (caddr_t)-1) {
+		if (ldcache == MAP_FAILED) {
 			ldcache = 0;
 			return NULL;
 		}






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2008-12-30 13:38 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2008-12-30 13:38 UTC (permalink / raw
  To: gentoo-commits

vapier      08/12/30 13:38:35

  Modified:             scanelf.c
  Log:
  use __PAX_UTILS_PATH_MAX, not BUFSIZ, when dealing with paths

Revision  Changes    Path
1.207                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.207&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.207&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.206&r2=1.207

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.206
retrieving revision 1.207
diff -u -r1.206 -r1.207
--- scanelf.c	30 Dec 2008 13:34:46 -0000	1.206
+++ scanelf.c	30 Dec 2008 13:38:35 -0000	1.207
@@ -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.206 2008/12/30 13:34:46 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.207 2008/12/30 13:38:35 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.206 2008/12/30 13:34:46 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.207 2008/12/30 13:38:35 vapier Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -81,7 +81,7 @@
 /* find the path to a file by name */
 static char *which(const char *fname)
 {
-	static char fullpath[BUFSIZ];
+	static char fullpath[__PAX_UTILS_PATH_MAX];
 	char *path, *p;
 
 	path = getenv("PATH");






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2009-03-15  8:53 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2009-03-15  8:53 UTC (permalink / raw
  To: gentoo-commits

vapier      09/03/15 08:53:29

  Modified:             scanelf.c
  Log:
  store return value of system() since gcc whines about it now, but dont actually use it since we dont care

Revision  Changes    Path
1.209                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.209&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.209&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.208&r2=1.209

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.208
retrieving revision 1.209
diff -u -r1.208 -r1.209
--- scanelf.c	31 Jan 2009 17:58:37 -0000	1.208
+++ scanelf.c	15 Mar 2009 08:53:29 -0000	1.209
@@ -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.208 2009/01/31 17:58:37 grobian Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.209 2009/03/15 08:53:29 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.208 2009/01/31 17:58:37 grobian Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.209 2009/03/15 08:53:29 vapier Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -475,6 +475,7 @@
 				Elf ## B ## _Addr end_addr = offset_tmp + EGET(func->st_size); \
 				char *sysbuf; \
 				size_t syslen; \
+				int sysret; \
 				const char sysfmt[] = "objdump -r -R -d -w -l --start-address=0x%lX --stop-address=0x%lX %s | grep --color -i -C 3 '.*[[:space:]]%lX:[[:space:]]*R_.*'\n"; \
 				syslen = sizeof(sysfmt) + strlen(elf->filename) + 3 * sizeof(unsigned long) + 1; \
 				sysbuf = xmalloc(syslen); \
@@ -487,7 +488,7 @@
 					elf->filename, \
 					(unsigned long)r_offset); \
 				fflush(stdout); \
-				system(sysbuf); \
+				sysret = system(sysbuf); \
 				fflush(stdout); \
 				free(sysbuf); \
 			} \






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2009-03-15  9:01 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2009-03-15  9:01 UTC (permalink / raw
  To: gentoo-commits

vapier      09/03/15 09:01:48

  Modified:             scanelf.c
  Log:
  fix dragonfly define check and tweak whitespace in scanelf_ldpath

Revision  Changes    Path
1.211                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.211&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.211&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.210&r2=1.211

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.210
retrieving revision 1.211
diff -u -r1.210 -r1.211
--- scanelf.c	15 Mar 2009 08:56:14 -0000	1.210
+++ scanelf.c	15 Mar 2009 09:01:48 -0000	1.211
@@ -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.210 2009/03/15 08:56:14 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.211 2009/03/15 09:01:48 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.210 2009/03/15 08:56:14 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.211 2009/03/15 09:01:48 vapier Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -1505,7 +1505,7 @@
 	return i;
 }
 
-#elif defined(__FreeBSD__) || (__DragonFly__)
+#elif defined(__FreeBSD__) || defined(__DragonFly__)
 
 static int load_ld_cache_config(int i, const char *fname)
 {
@@ -1571,8 +1571,8 @@
 	scan_l = scan_ul = scan_ull = 0;
 
 	while (ldpaths[i]) {
-		if (!scan_l   && !strcmp(ldpaths[i], "/lib")) scan_l = 1;
-		if (!scan_ul  && !strcmp(ldpaths[i], "/usr/lib")) scan_ul = 1;
+		if (!scan_l   && !strcmp(ldpaths[i], "/lib"))           scan_l   = 1;
+		if (!scan_ul  && !strcmp(ldpaths[i], "/usr/lib"))       scan_ul  = 1;
 		if (!scan_ull && !strcmp(ldpaths[i], "/usr/local/lib")) scan_ull = 1;
 		scanelf_dir(ldpaths[i]);
 		++i;






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2009-03-15  9:13 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2009-03-15  9:13 UTC (permalink / raw
  To: gentoo-commits

vapier      09/03/15 09:13:20

  Modified:             scanelf.c
  Log:
  cleanup lookup_cache_lib() and return first match, not last #258090

Revision  Changes    Path
1.212                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.212&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.212&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.211&r2=1.212

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.211
retrieving revision 1.212
diff -u -r1.211 -r1.212
--- scanelf.c	15 Mar 2009 09:01:48 -0000	1.211
+++ scanelf.c	15 Mar 2009 09:13:20 -0000	1.212
@@ -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.211 2009/03/15 09:01:48 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.212 2009/03/15 09:13:20 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.211 2009/03/15 09:01:48 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.212 2009/03/15 09:13:20 vapier Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -72,7 +72,7 @@
 
 static int match_bits = 0;
 static unsigned int match_perms = 0;
-static caddr_t ldcache = 0;
+static void *ldcache = NULL;
 static size_t ldcache_size = 0;
 static unsigned long setpax = 0UL;
 
@@ -694,10 +694,10 @@
 
 static char *lookup_cache_lib(elfobj *elf, char *fname)
 {
-	int fd = 0;
+	int fd;
 	char *strs;
 	static char buf[__PAX_UTILS_PATH_MAX] = "";
-	const char *cachefile = "/etc/ld.so.cache";
+	const char cachefile[] = "/etc/ld.so.cache";
 	struct stat st;
 
 	typedef struct {
@@ -717,35 +717,42 @@
 	if (fname == NULL)
 		return NULL;
 
-	if (ldcache == 0) {
-		if (stat(cachefile, &st) || (fd = open(cachefile, O_RDONLY)) == -1)
+	if (ldcache == NULL) {
+		if (stat(cachefile, &st))
+			return NULL;
+
+		fd = open(cachefile, O_RDONLY);
+		if (fd == -1)
 			return NULL;
 
 		/* cache these values so we only map/unmap the cache file once */
 		ldcache_size = st.st_size;
-		ldcache = mmap(0, ldcache_size, PROT_READ, MAP_SHARED, fd, 0);
-
+		header = ldcache = mmap(0, ldcache_size, PROT_READ, MAP_SHARED, fd, 0);
 		close(fd);
 
 		if (ldcache == MAP_FAILED) {
-			ldcache = 0;
+			ldcache = NULL;
 			return NULL;
 		}
 
-		if (memcmp(((header_t *) ldcache)->magic, LDSO_CACHE_MAGIC, LDSO_CACHE_MAGIC_LEN))
-			return NULL;
-		if (memcmp (((header_t *) ldcache)->version, LDSO_CACHE_VER, LDSO_CACHE_VER_LEN))
+		if (memcmp(header->magic, LDSO_CACHE_MAGIC, LDSO_CACHE_MAGIC_LEN) ||
+		    memcmp(header->version, LDSO_CACHE_VER, LDSO_CACHE_VER_LEN))
+		{
+			munmap(ldcache, ldcache_size);
+			ldcache = NULL;
 			return NULL;
-	}
+		}
+	} else
+		header = ldcache;
 
-	header = (header_t *) ldcache;
-	libent = (libentry_t *) (ldcache + sizeof(header_t));
+	libent = ldcache + sizeof(header_t);
 	strs = (char *) &libent[header->nlibs];
 
-	for (fd = 0; fd < header->nlibs; fd++) {
-		/* this should be more fine grained, but for now we assume that
-		 * diff arches will not be cached together.  and we ignore the
-		 * the different multilib mips cases. */
+	for (fd = 0; fd < header->nlibs; ++fd) {
+		/* This should be more fine grained, but for now we assume that
+		 * diff arches will not be cached together, and we ignore the
+		 * the different multilib mips cases.
+		 */
 		if (elf->elf_class == ELFCLASS64 && !(libent[fd].flags & FLAG_REQUIRED_MASK))
 			continue;
 		if (elf->elf_class == ELFCLASS32 && (libent[fd].flags & FLAG_REQUIRED_MASK))
@@ -753,10 +760,15 @@
 
 		if (strcmp(fname, strs + libent[fd].sooffset) != 0)
 			continue;
+
+		/* Return first hit because that is how the ldso rolls */
 		strncpy(buf, strs + libent[fd].liboffset, sizeof(buf));
+		break;
 	}
+
 	return buf;
 }
+
 #elif defined(__NetBSD__)
 static char *lookup_cache_lib(elfobj *elf, char *fname)
 {






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2009-12-01 10:18 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2009-12-01 10:18 UTC (permalink / raw
  To: gentoo-commits

vapier      09/12/01 10:18:58

  Modified:             scanelf.c
  Log:
  unify some of the scanelf symtabs code paths

Revision  Changes    Path
1.213                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.213&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.213&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.212&r2=1.213

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.212
retrieving revision 1.213
diff -u -r1.212 -r1.213
--- scanelf.c	15 Mar 2009 09:13:20 -0000	1.212
+++ scanelf.c	1 Dec 2009 10:18:58 -0000	1.213
@@ -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.212 2009/03/15 09:13:20 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.213 2009/12/01 10:18:58 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.212 2009/03/15 09:13:20 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.213 2009/12/01 10:18:58 vapier Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -130,25 +130,28 @@
 static void scanelf_file_get_symtabs(elfobj *elf, void **sym, void **tab)
 {
 	/* find the best SHT_DYNSYM and SHT_STRTAB sections */
+
+	/* debug sections */
+	void *symtab = elf_findsecbyname(elf, ".symtab");
+	void *strtab = elf_findsecbyname(elf, ".strtab");
+	/* runtime sections */
+	void *dynsym = elf_findsecbyname(elf, ".dynsym");
+	void *dynstr = elf_findsecbyname(elf, ".dynstr");
+
 #define GET_SYMTABS(B) \
 	if (elf->elf_class == ELFCLASS ## B) { \
-		Elf ## B ## _Shdr *symtab, *strtab, *dynsym, *dynstr; \
-		/* debug sections */ \
-		symtab = SHDR ## B (elf_findsecbyname(elf, ".symtab")); \
-		strtab = SHDR ## B (elf_findsecbyname(elf, ".strtab")); \
-		/* runtime sections */ \
-		dynsym = SHDR ## B (elf_findsecbyname(elf, ".dynsym")); \
-		dynstr = SHDR ## B (elf_findsecbyname(elf, ".dynstr")); \
-		if (symtab && dynsym) { \
-			*sym = (void*)((EGET(symtab->sh_size) > EGET(dynsym->sh_size)) ? symtab : dynsym); \
-		} else { \
-			*sym = (void*)(symtab ? symtab : dynsym); \
-		} \
-		if (strtab && dynstr) { \
-			*tab = (void*)((EGET(strtab->sh_size) > EGET(dynstr->sh_size)) ? strtab : dynstr); \
-		} else { \
-			*tab = (void*)(strtab ? strtab : dynstr); \
-		} \
+	if (symtab && dynsym) { \
+		Elf ## B ## _Shdr *esymtab = symtab; \
+		Elf ## B ## _Shdr *edynsym = dynsym; \
+		*sym = (EGET(esymtab->sh_size) > EGET(edynsym->sh_size)) ? symtab : dynsym; \
+	} else \
+		*sym = symtab ? symtab : dynsym; \
+	if (strtab && dynstr) { \
+		Elf ## B ## _Shdr *estrtab = strtab; \
+		Elf ## B ## _Shdr *edynstr = dynstr; \
+		*tab = (EGET(estrtab->sh_size) > EGET(edynstr->sh_size)) ? strtab : dynstr; \
+	} else \
+		*tab = strtab ? strtab : dynstr; \
 	}
 	GET_SYMTABS(32)
 	GET_SYMTABS(64)






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2009-12-20 20:25 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2009-12-20 20:25 UTC (permalink / raw
  To: gentoo-commits

vapier      09/12/20 20:25:04

  Modified:             scanelf.c
  Log:
  tweak -a description #236540

Revision  Changes    Path
1.216                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.216&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.216&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.215&r2=1.216

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.215
retrieving revision 1.216
diff -u -r1.215 -r1.216
--- scanelf.c	3 Dec 2009 08:01:45 -0000	1.215
+++ scanelf.c	20 Dec 2009 20:25:04 -0000	1.216
@@ -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.215 2009/12/03 08:01:45 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.216 2009/12/20 20:25:04 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.215 2009/12/03 08:01:45 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.216 2009/12/20 20:25:04 vapier Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -1803,7 +1803,7 @@
 	"Print EABI (EM_ARM Only)",
 	"Print only ELF files matching octal permissions",
 	"Print ELF file size",
-	"Print all scanned info (-x -e -t -r -b)\n",
+	"Print all useful/simple info\n",
 	"Only output 'bad' things",
 	"Be verbose (can be specified more than once)",
 	"Use specified format for output",






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2010-01-15 11:56 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2010-01-15 11:56 UTC (permalink / raw
  To: gentoo-commits

vapier      10/01/15 11:56:15

  Modified:             scanelf.c
  Log:
  check return value of lseek for errors

Revision  Changes    Path
1.218                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.218&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?rev=1.218&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanelf.c?r1=1.217&r2=1.218

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.217
retrieving revision 1.218
diff -u -r1.217 -r1.218
--- scanelf.c	15 Jan 2010 10:29:17 -0000	1.217
+++ scanelf.c	15 Jan 2010 11:56:15 -0000	1.218
@@ -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.217 2010/01/15 10:29:17 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.218 2010/01/15 11:56:15 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.217 2010/01/15 10:29:17 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.218 2010/01/15 11:56:15 vapier Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -1449,8 +1449,11 @@
 		return 1;
 
 	ar_buffer = mmap(0, len, PROT_READ | (fix_elf ? PROT_WRITE : 0), (fix_elf ? MAP_SHARED : MAP_PRIVATE), fd, 0);
-	while ((m=ar_next(ar)) != NULL) {
-		elf = readelf_buffer(m->name, ar_buffer+lseek(fd,0,SEEK_CUR), m->size);
+	while ((m = ar_next(ar)) != NULL) {
+		off_t cur_pos = lseek(fd, 0, SEEK_CUR);
+		if (cur_pos == -1)
+			errp("lseek() failed");
+		elf = readelf_buffer(m->name, ar_buffer + cur_pos, m->size);
 		if (elf) {
 			scanelf_elfobj(elf);
 			unreadelf(elf);






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2010-12-06 20:43 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2010-12-06 20:43 UTC (permalink / raw
  To: gentoo-commits

vapier      10/12/06 20:43:48

  Modified:             scanelf.c
  Log:
  use normal glob funcs rather than hardcoding 64bit vers since _GNU_SOURCE should transparently rewrite these to 64bit when feasible

Revision  Changes    Path
1.219                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.219&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.219&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.218&r2=1.219

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.218
retrieving revision 1.219
diff -u -r1.218 -r1.219
--- scanelf.c	15 Jan 2010 11:56:15 -0000	1.218
+++ scanelf.c	6 Dec 2010 20:43:48 -0000	1.219
@@ -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.218 2010/01/15 11:56:15 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.219 2010/12/06 20:43:48 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.218 2010/01/15 11:56:15 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.219 2010/12/06 20:43:48 vapier Exp $";
 const char * const argv0 = "scanelf";
 
 #include "paxinc.h"
@@ -1591,10 +1591,10 @@
 			*p = 0;
 		if ((p = strchr(path, '\n')) != NULL)
 			*p = 0;
-#ifdef __linux__
+
 		/* recursive includes of the same file will make this segfault. */
 		if ((memcmp(path, "include", 7) == 0) && isblank(path[7])) {
-			glob64_t gl;
+			glob_t gl;
 			size_t x;
 			char gpath[__PAX_UTILS_PATH_MAX];
 
@@ -1605,22 +1605,22 @@
 			else
 				strncpy(gpath, &path[8], sizeof(gpath));
 
-			if ((glob64(gpath, 0, NULL, &gl)) == 0) {
+			if (glob(gpath, 0, NULL, &gl) == 0) {
 				for (x = 0; x < gl.gl_pathc; ++x) {
 					/* try to avoid direct loops */
 					if (strcmp(gl.gl_pathv[x], fname) == 0)
 						continue;
 					i = load_ld_cache_config(i, gl.gl_pathv[x]);
 					if (i + 1 >= ARRAY_SIZE(ldpaths)) {
-						globfree64(&gl);
+						globfree(&gl);
 						return i;
 					}
 				}
-				globfree64 (&gl);
+				globfree(&gl);
 				continue;
 			}
 		}
-#endif
+
 		if (*path != '/')
 			continue;
 






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2011-07-30 17:08 Ned Ludd (solar)
  0 siblings, 0 replies; 62+ messages in thread
From: Ned Ludd (solar) @ 2011-07-30 17:08 UTC (permalink / raw
  To: gentoo-commits

solar       11/07/30 17:08:30

  Modified:             scanelf.c
  Log:
  [PATCH pax-utils 1/2] add --root option # Ludwig Nussel <ludwig.nussel@suse.de>

Revision  Changes    Path
1.223                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.223&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.223&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.222&r2=1.223

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.222
retrieving revision 1.223
diff -u -r1.222 -r1.223
--- scanelf.c	8 Dec 2010 01:24:01 -0000	1.222
+++ scanelf.c	30 Jul 2011 17:08:30 -0000	1.223
@@ -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.222 2010/12/08 01:24:01 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.223 2011/07/30 17:08:30 solar Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.222 2010/12/08 01:24:01 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.223 2011/07/30 17:08:30 solar Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -68,6 +68,7 @@
 static char **qa_textrels = NULL;
 static char **qa_execstack = NULL;
 static char **qa_wx_load = NULL;
+static char *root;
 
 static int match_bits = 0;
 static unsigned int match_perms = 0;
@@ -1497,6 +1498,16 @@
 	return 0;
 }
 
+static const char* maybe_add_root(const char* fname, char* buf)
+{
+	if (root && strncmp(fname, root, strlen(root))) {
+		strcpy(buf, root);
+		strncat(buf, fname, __PAX_UTILS_PATH_MAX-strlen(root)-1);
+		fname = buf;
+	}
+	return fname;
+}
+
 /* scan a directory for ET_EXEC files and print when we find one */
 static int scanelf_dir(const char *path)
 {
@@ -1504,9 +1515,12 @@
 	register struct dirent *dentry;
 	struct stat st_top, st;
 	char buf[__PAX_UTILS_PATH_MAX];
+	char _path[__PAX_UTILS_PATH_MAX];
 	size_t pathlen = 0, len = 0;
 	int ret = 0;
 
+	path = maybe_add_root(path, _path);
+
 	/* make sure path exists */
 	if (lstat(path, &st_top) == -1) {
 		if (be_verbose > 2) printf("%s: does not exist\n", path);
@@ -1579,6 +1593,9 @@
 	FILE *fp = NULL;
 	char *p;
 	char path[__PAX_UTILS_PATH_MAX];
+	char _fname[__PAX_UTILS_PATH_MAX];
+
+	fname = maybe_add_root(fname, _fname);
 
 	if (i + 1 == ARRAY_SIZE(ldpaths))
 		return i;
@@ -1599,11 +1616,13 @@
 			char gpath[__PAX_UTILS_PATH_MAX];
 
 			memset(gpath, 0, sizeof(gpath));
+			if (root)
+				strcpy(gpath, root);
 
 			if (path[8] != '/')
-				snprintf(gpath, sizeof(gpath), "/etc/%s", &path[8]);
+				snprintf(gpath+strlen(gpath), sizeof(gpath)-strlen(gpath), "/etc/%s", &path[8]);
 			else
-				strncpy(gpath, &path[8], sizeof(gpath));
+				strncpy(gpath+strlen(gpath), &path[8], sizeof(gpath)-strlen(gpath));
 
 			if (glob(gpath, 0, NULL, &gl) == 0) {
 				for (x = 0; x < gl.gl_pathc; ++x) {
@@ -1642,6 +1661,9 @@
 	FILE *fp = NULL;
 	char *b = NULL, *p;
 	struct elfhints_hdr hdr;
+	char _fname[__PAX_UTILS_PATH_MAX];
+
+	fname = maybe_add_root(fname, _fname);
 
 	if (i + 1 == ARRAY_SIZE(ldpaths))
 		return i;
@@ -1737,6 +1759,7 @@
 static struct option const long_opts[] = {
 	{"path",      no_argument, NULL, 'p'},
 	{"ldpath",    no_argument, NULL, 'l'},
+	{"root",       a_argument, NULL, 128},
 	{"recursive", no_argument, NULL, 'R'},
 	{"mount",     no_argument, NULL, 'm'},
 	{"symlink",   no_argument, NULL, 'y'},
@@ -1780,6 +1803,7 @@
 static const char * const opts_help[] = {
 	"Scan all directories in PATH environment",
 	"Scan all directories in /etc/ld.so.conf",
+	"Root directory (use with -l or -p)",
 	"Scan directories recursively",
 	"Don't recursively cross mount points",
 	"Don't scan symlinks",
@@ -1831,6 +1855,9 @@
 		if (long_opts[i].has_arg == no_argument)
 			printf("  -%c, --%-14s* %s\n", long_opts[i].val,
 			       long_opts[i].name, opts_help[i]);
+		else if (long_opts[i].val > '~')
+			printf("      --%-7s <arg> * %s\n",
+			       long_opts[i].name, opts_help[i]);
 		else
 			printf("  -%c, --%-7s <arg> * %s\n", long_opts[i].val,
 			       long_opts[i].name, opts_help[i]);
@@ -1980,6 +2007,9 @@
 		case 'D': show_endian = 1; break;
 		case 'I': show_osabi = 1; break;
 		case 'Y': show_eabi = 1; break;
+		case 128:
+			root = optarg;
+			break;
 		case ':':
 			err("Option '%c' is missing parameter", optopt);
 		case '?':






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2011-08-08  1:56 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2011-08-08  1:56 UTC (permalink / raw
  To: gentoo-commits

vapier      11/08/08 01:56:16

  Modified:             scanelf.c
  Log:
  fixup style in previous root patch

Revision  Changes    Path
1.224                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.224&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.224&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.223&r2=1.224

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.223
retrieving revision 1.224
diff -u -r1.223 -r1.224
--- scanelf.c	30 Jul 2011 17:08:30 -0000	1.223
+++ scanelf.c	8 Aug 2011 01:56:16 -0000	1.224
@@ -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.223 2011/07/30 17:08:30 solar Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.224 2011/08/08 01:56:16 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.223 2011/07/30 17:08:30 solar Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.224 2011/08/08 01:56:16 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -1498,11 +1498,11 @@
 	return 0;
 }
 
-static const char* maybe_add_root(const char* fname, char* buf)
+static const char *maybe_add_root(const char *fname, char *buf)
 {
 	if (root && strncmp(fname, root, strlen(root))) {
 		strcpy(buf, root);
-		strncat(buf, fname, __PAX_UTILS_PATH_MAX-strlen(root)-1);
+		strncat(buf, fname, __PAX_UTILS_PATH_MAX - strlen(root) - 1);
 		fname = buf;
 	}
 	return fname;






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2011-09-27 17:28 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2011-09-27 17:28 UTC (permalink / raw
  To: gentoo-commits

vapier      11/09/27 17:28:19

  Modified:             scanelf.c
  Log:
  constify the return of scanelf_file_{sections,sym}

Revision  Changes    Path
1.225                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.225&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.225&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.224&r2=1.225

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.224
retrieving revision 1.225
diff -u -r1.224 -r1.225
--- scanelf.c	8 Aug 2011 01:56:16 -0000	1.224
+++ scanelf.c	27 Sep 2011 17:28:19 -0000	1.225
@@ -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.224 2011/08/08 01:56:16 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.225 2011/09/27 17:28:19 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.224 2011/08/08 01:56:16 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.225 2011/09/27 17:28:19 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -1146,7 +1146,7 @@
 		next_sym[-1] = saved;
 }
 
-static char *scanelf_file_sym(elfobj *elf, char *found_sym)
+static const char *scanelf_file_sym(elfobj *elf, char *found_sym)
 {
 	unsigned long i;
 	char *ret;
@@ -1203,10 +1203,10 @@
 	if (be_quiet)
 		return NULL;
 	else
-		return (char *)" - ";
+		return " - ";
 }
 
-static char *scanelf_file_sections(elfobj *elf, char *found_section)
+static const char *scanelf_file_sections(elfobj *elf, char *found_section)
 {
 	if (!find_section)
 		 return NULL;
@@ -1232,7 +1232,7 @@
 	if (be_quiet)
 		return NULL;
 	else
-		return (char *)" - ";
+		return " - ";
 }
 
 /* scan an elf file and show all the fun stuff */






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2011-09-27 19:20 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2011-09-27 19:20 UTC (permalink / raw
  To: gentoo-commits

vapier      11/09/27 19:20:52

  Modified:             scanelf.c
  Log:
  convert ldpaths over to new array code to make it easier to maintain

Revision  Changes    Path
1.227                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.227&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.227&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.226&r2=1.227

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.226
retrieving revision 1.227
diff -u -r1.226 -r1.227
--- scanelf.c	27 Sep 2011 18:37:22 -0000	1.226
+++ scanelf.c	27 Sep 2011 19:20:51 -0000	1.227
@@ -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.226 2011/09/27 18:37:22 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.227 2011/09/27 19:20:51 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.226 2011/09/27 18:37:22 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.227 2011/09/27 19:20:51 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -30,7 +30,7 @@
 
 /* variables to control behavior */
 static char match_etypes[126] = "";
-static char *ldpaths[256];
+static array_t _ldpaths = array_init_decl, *ldpaths = &_ldpaths;
 static char scan_ldpath = 0;
 static char scan_envpath = 0;
 static char scan_symlink = 1;
@@ -534,7 +534,7 @@
 }
 static void scanelf_file_rpath(elfobj *elf, char *found_rpath, char **ret, size_t *ret_len)
 {
-	unsigned long i, s;
+	unsigned long i;
 	char *rpath, *runpath, **r;
 	void *strtbl_void;
 
@@ -589,9 +589,11 @@
 							rpath_security_checks(elf, start, get_elfdtype(word)); \
 							end = strchr(start, ':'); \
 							len = (end ? abs(end - start) : strlen(start)); \
-							if (use_ldcache) \
-								for (s = 0; ldpaths[s]; ++s) \
-									if (!strncmp(ldpaths[s], start, len) && !ldpaths[s][len]) { \
+							if (use_ldcache) { \
+								size_t n; \
+								const char *ldpath; \
+								array_for_each(ldpaths, n, ldpath) \
+									if (!strncmp(ldpath, start, len) && !ldpath[len]) { \
 										*r = end; \
 										/* corner case ... if RPATH reads "/usr/lib:", we want \
 										 * to show ':' rather than '' */ \
@@ -599,6 +601,7 @@
 											(*r)++; \
 										break; \
 									} \
+							} \
 							if (!*r || !end) \
 								break; \
 							else \
@@ -779,10 +782,11 @@
 {
 	static char buf[__PAX_UTILS_PATH_MAX] = "";
 	static struct stat st;
+	size_t n;
+	char *ldpath;
 
-	char **ldpath;
-	for (ldpath = ldpaths; *ldpath != NULL; ldpath++) {
-		if ((unsigned) snprintf(buf, sizeof(buf), "%s/%s", *ldpath, fname) >= sizeof(buf))
+	array_for_each(ldpath, n, ldpath) {
+		if ((unsigned) snprintf(buf, sizeof(buf), "%s/%s", ldpath, fname) >= sizeof(buf))
 			continue; /* if the pathname is too long, or something went wrong, ignore */
 
 		if (stat(buf, &st) != 0)
@@ -1627,9 +1631,6 @@
 
 	fname = maybe_add_root(fname, _fname);
 
-	if (i + 1 == ARRAY_SIZE(ldpaths))
-		return i;
-
 	if ((fp = fopen(fname, "r")) == NULL)
 		return i;
 
@@ -1660,10 +1661,6 @@
 					if (strcmp(gl.gl_pathv[x], fname) == 0)
 						continue;
 					i = load_ld_cache_config(i, gl.gl_pathv[x]);
-					if (i + 1 >= ARRAY_SIZE(ldpaths)) {
-						globfree(&gl);
-						return i;
-					}
 				}
 				globfree(&gl);
 				continue;
@@ -1673,12 +1670,8 @@
 		if (*path != '/')
 			continue;
 
-		ldpaths[i++] = xstrdup(path);
-
-		if (i + 1 == ARRAY_SIZE(ldpaths))
-			break;
+		xarraypush(ldpaths, path, strlen(path));
 	}
-	ldpaths[i] = NULL;
 
 	fclose(fp);
 	return i;
@@ -1695,9 +1688,6 @@
 
 	fname = maybe_add_root(fname, _fname);
 
-	if (i + 1 == ARRAY_SIZE(ldpaths))
-		return i;
-
 	if ((fp = fopen(fname, "r")) == NULL)
 		return i;
 
@@ -1717,13 +1707,10 @@
 	}
 
 	while ((p = strsep(&b, ":"))) {
-		if (*p == '\0') continue;
-		ldpaths[i++] = xstrdup(p);
-
-		if (i + 1 == ARRAY_SIZE(ldpaths))
-			break;
+		if (*p == '\0')
+			continue;
+		xarraypush(ldpaths, p, strlen(p));
 	}
-	ldpaths[i] = NULL;
 
 	free(b);
 	fclose(fp);
@@ -1736,7 +1723,6 @@
 #endif
 static int load_ld_cache_config(int i, const char *fname)
 {
-	memset(ldpaths, 0x00, sizeof(ldpaths));
 	return 0;
 }
 #endif
@@ -1745,18 +1731,20 @@
 static void scanelf_ldpath(void)
 {
 	char scan_l, scan_ul, scan_ull;
+	size_t n;
+	const char *ldpath;
 	int i = 0;
 
-	if (!ldpaths[0])
+	if (array_cnt(ldpaths) == 0)
 		err("Unable to load any paths from ld.so.conf");
 
 	scan_l = scan_ul = scan_ull = 0;
 
-	while (ldpaths[i]) {
-		if (!scan_l   && !strcmp(ldpaths[i], "/lib"))           scan_l   = 1;
-		if (!scan_ul  && !strcmp(ldpaths[i], "/usr/lib"))       scan_ul  = 1;
-		if (!scan_ull && !strcmp(ldpaths[i], "/usr/local/lib")) scan_ull = 1;
-		scanelf_dir(ldpaths[i]);
+	array_for_each(ldpaths, n, ldpath) {
+		if (!scan_l   && !strcmp(ldpath, "/lib"))           scan_l   = 1;
+		if (!scan_ul  && !strcmp(ldpath, "/usr/lib"))       scan_ul  = 1;
+		if (!scan_ull && !strcmp(ldpath, "/usr/local/lib")) scan_ull = 1;
+		scanelf_dir(ldpath);
 		++i;
 	}
 
@@ -2141,8 +2129,9 @@
 	}
 
 	/* clean up */
-	for (i = 0; ldpaths[i]; ++i)
-		free(ldpaths[i]);
+	xarrayfree(ldpaths);
+	xarrayfree(find_lib_arr);
+	xarrayfree(find_section_arr);
 	free(find_lib);
 	free(find_section);
 






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2011-09-27 19:21 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2011-09-27 19:21 UTC (permalink / raw
  To: gentoo-commits

vapier      11/09/27 19:21:56

  Modified:             scanelf.c
  Log:
  simplify match_etype logic

Revision  Changes    Path
1.228                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.228&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.228&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.227&r2=1.228

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.227
retrieving revision 1.228
diff -u -r1.227 -r1.228
--- scanelf.c	27 Sep 2011 19:20:51 -0000	1.227
+++ scanelf.c	27 Sep 2011 19:21:56 -0000	1.228
@@ -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.227 2011/09/27 19:20:51 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.228 2011/09/27 19:21:56 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.227 2011/09/27 19:20:51 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.228 2011/09/27 19:21:56 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -29,7 +29,7 @@
 static int parseargs(int argc, char *argv[]);
 
 /* variables to control behavior */
-static char match_etypes[126] = "";
+static char *match_etypes = NULL;
 static array_t _ldpaths = array_init_decl, *ldpaths = &_ldpaths;
 static char scan_ldpath = 0;
 static char scan_envpath = 0;
@@ -1448,7 +1448,7 @@
 			break;
 		default: break;
 	}
-	if (strlen(match_etypes)) {
+	if (match_etypes) {
 		char sbuf[126];
 		strncpy(sbuf, match_etypes, sizeof(sbuf));
 		if (strchr(match_etypes, ',') != NULL) {
@@ -1915,7 +1915,7 @@
 			from_file = optarg;
 			break;
 		case 'E':
-			strncpy(match_etypes, optarg, sizeof(match_etypes));
+			match_etypes = optarg;
 			break;
 		case 'M':
 			match_bits = atoi(optarg);






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2011-09-27 19:29 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2011-09-27 19:29 UTC (permalink / raw
  To: gentoo-commits

vapier      11/09/27 19:29:19

  Modified:             scanelf.c
  Log:
  remove useless duplicate prototypes

Revision  Changes    Path
1.229                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.229&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.229&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.228&r2=1.229

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.228
retrieving revision 1.229
diff -u -r1.228 -r1.229
--- scanelf.c	27 Sep 2011 19:21:56 -0000	1.228
+++ scanelf.c	27 Sep 2011 19:29:19 -0000	1.229
@@ -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.228 2011/09/27 19:21:56 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.229 2011/09/27 19:29:19 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.228 2011/09/27 19:21:56 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.229 2011/09/27 19:29:19 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -16,17 +16,6 @@
 
 /* prototypes */
 static int file_matches_list(const char *filename, char **matchlist);
-static int scanelf_elfobj(elfobj *elf);
-static int scanelf_elf(const char *filename, int fd, size_t len);
-static int scanelf_archive(const char *filename, int fd, size_t len);
-static int scanelf_file(const char *filename, const struct stat *st_cache);
-static int scanelf_dir(const char *path);
-static void scanelf_ldpath(void);
-static void scanelf_envpath(void);
-static void usage(int status);
-static char **get_split_env(const char *envvar);
-static void parseenv(void);
-static int parseargs(int argc, char *argv[]);
 
 /* variables to control behavior */
 static char *match_etypes = NULL;
@@ -508,7 +497,6 @@
 	return NULL;
 }
 
-static void rpath_security_checks(elfobj *, char *, const char *);
 static void rpath_security_checks(elfobj *elf, char *item, const char *dt_type)
 {
 	struct stat st;
@@ -696,8 +684,6 @@
 #define FLAG_MIPS64_LIBN32  0x0600
 #define FLAG_MIPS64_LIBN64  0x0700
 
-static char *lookup_cache_lib(elfobj *, char *);
-
 #if defined(__GLIBC__) || defined(__UCLIBC__)
 
 static char *lookup_cache_lib(elfobj *elf, char *fname)






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2011-09-27 19:56 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2011-09-27 19:56 UTC (permalink / raw
  To: gentoo-commits

vapier      11/09/27 19:56:15

  Modified:             scanelf.c
  Log:
  convert fgets() to getline(), and simplify which() to avoid memory allocation

Revision  Changes    Path
1.230                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.230&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.230&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.229&r2=1.230

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.229
retrieving revision 1.230
diff -u -r1.229 -r1.230
--- scanelf.c	27 Sep 2011 19:29:19 -0000	1.229
+++ scanelf.c	27 Sep 2011 19:56:15 -0000	1.230
@@ -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.229 2011/09/27 19:29:19 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.230 2011/09/27 19:56:15 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char *rcsid = "$Id: scanelf.c,v 1.229 2011/09/27 19:29:19 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.230 2011/09/27 19:56:15 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -70,26 +70,23 @@
 static int has_objdump = 0;
 
 /* find the path to a file by name */
-static char *which(const char *fname)
+static int bin_in_path(const char *fname)
 {
-	static char fullpath[__PAX_UTILS_PATH_MAX];
+	char fullpath[__PAX_UTILS_PATH_MAX];
 	char *path, *p;
 
 	path = getenv("PATH");
 	if (!path)
-		return NULL;
+		return 0;
 
-	path = xstrdup(path);
 	while ((p = strrchr(path, ':')) != NULL) {
 		snprintf(fullpath, sizeof(fullpath), "%s/%s", p + 1, fname);
 		*p = 0;
-		if (access(fullpath, R_OK) != -1) {
-			free(path);
-			return fullpath;
-		}
+		if (access(fullpath, R_OK) != -1)
+			return 1;
 	}
-	free(path);
-	return NULL;
+
+	return 0;
 }
 
 /* 1 on failure. 0 otherwise */
@@ -1585,24 +1582,30 @@
 
 static int scanelf_from_file(const char *filename)
 {
-	FILE *fp = NULL;
-	char *p;
-	char path[__PAX_UTILS_PATH_MAX];
-	int ret = 0;
+	FILE *fp;
+	char *p, *path;
+	size_t len;
+	int ret;
 
 	if (strcmp(filename, "-") == 0)
 		fp = stdin;
 	else if ((fp = fopen(filename, "r")) == NULL)
 		return 1;
 
-	while ((fgets(path, __PAX_UTILS_PATH_MAX, fp)) != NULL) {
+	path = NULL;
+	len = 0;
+	ret = 0;
+	while (getline(&path, &len, fp) != -1) {
 		if ((p = strchr(path, '\n')) != NULL)
 			*p = 0;
 		search_path = path;
 		ret = scanelf_dir(path);
 	}
+	free(path);
+
 	if (fp != stdin)
 		fclose(fp);
+
 	return ret;
 }
 
@@ -1611,8 +1614,8 @@
 static int load_ld_cache_config(int i, const char *fname)
 {
 	FILE *fp = NULL;
-	char *p;
-	char path[__PAX_UTILS_PATH_MAX];
+	char *p, *path;
+	size_t len;
 	char _fname[__PAX_UTILS_PATH_MAX];
 
 	fname = maybe_add_root(fname, _fname);
@@ -1620,7 +1623,9 @@
 	if ((fp = fopen(fname, "r")) == NULL)
 		return i;
 
-	while ((fgets(path, __PAX_UTILS_PATH_MAX, fp)) != NULL) {
+	path = NULL;
+	len = 0;
+	while (getline(&path, &len, fp) != -1) {
 		if ((p = strrchr(path, '\r')) != NULL)
 			*p = 0;
 		if ((p = strchr(path, '\n')) != NULL)
@@ -1658,8 +1663,10 @@
 
 		xarraypush(ldpaths, path, strlen(path));
 	}
+	free(path);
 
 	fclose(fp);
+
 	return i;
 }
 
@@ -2018,10 +2025,8 @@
 			err("Unhandled option '%c'; please report this", i);
 		}
 	}
-	if (show_textrels && be_verbose) {
-		if (which("objdump") != NULL)
-			has_objdump = 1;
-	}
+	if (show_textrels && be_verbose)
+		has_objdump = bin_in_path("objdump");
 	/* flatten arrays for display */
 	if (array_cnt(find_lib_arr))
 		find_lib = array_flatten_str(find_lib_arr);






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2011-09-27 22:20 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2011-09-27 22:20 UTC (permalink / raw
  To: gentoo-commits

vapier      11/09/27 22:20:07

  Modified:             scanelf.c
  Log:
  redo root support to use *at funcs and avoid memory operations where possible

Revision  Changes    Path
1.232                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.232&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.232&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.231&r2=1.232

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.231
retrieving revision 1.232
diff -u -r1.231 -r1.232
--- scanelf.c	27 Sep 2011 19:58:09 -0000	1.231
+++ scanelf.c	27 Sep 2011 22:20:07 -0000	1.232
@@ -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.231 2011/09/27 19:58:09 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.232 2011/09/27 22:20:07 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.231 2011/09/27 19:58:09 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.232 2011/09/27 22:20:07 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -59,7 +59,7 @@
 static char **qa_textrels = NULL;
 static char **qa_execstack = NULL;
 static char **qa_wx_load = NULL;
-static char *root;
+static int root_fd = AT_FDCWD;
 
 static int match_bits = 0;
 static unsigned int match_perms = 0;
@@ -89,6 +89,34 @@
 	return 0;
 }
 
+static FILE *fopenat_r(int dir_fd, const char *path)
+{
+	int fd = openat(dir_fd, path, O_RDONLY|O_CLOEXEC);
+	if (fd == -1)
+		return NULL;
+	return fdopen(fd, "re");
+}
+
+static const char *root_rel_path(const char *path)
+{
+	/*
+	 * openat() will ignore the dirfd if path starts with
+	 * a /, so consume all of that noise
+	 *
+	 * XXX: we don't handle relative paths like ../ that
+	 * break out of the --root option, but for now, just
+	 * don't do that :P.
+	 */
+	if (root_fd != AT_FDCWD) {
+		while (*path == '/')
+			++path;
+		if (*path == '\0')
+			path = ".";
+	}
+
+	return path;
+}
+
 /* 1 on failure. 0 otherwise */
 static int rematch(const char *regex, const char *match, int cflags)
 {
@@ -114,7 +142,7 @@
 	return ret;
 }
 
-/* sub-funcs for scanelf_file() */
+/* sub-funcs for scanelf_fileat() */
 static void scanelf_file_get_symtabs(elfobj *elf, void **sym, void **tab)
 {
 	/* find the best SHT_DYNSYM and SHT_STRTAB sections */
@@ -466,7 +494,6 @@
 				Elf ## B ## _Addr end_addr = offset_tmp + EGET(func->st_size); \
 				char *sysbuf; \
 				size_t syslen; \
-				int sysret; \
 				const char sysfmt[] = "objdump -r -R -d -w -l --start-address=0x%lX --stop-address=0x%lX %s | grep --color -i -C 3 '.*[[:space:]]%lX:[[:space:]]*R_.*'\n"; \
 				syslen = sizeof(sysfmt) + strlen(elf->filename) + 3 * sizeof(unsigned long) + 1; \
 				sysbuf = xmalloc(syslen); \
@@ -479,7 +506,7 @@
 					elf->filename, \
 					(unsigned long)r_offset); \
 				fflush(stdout); \
-				sysret = system(sysbuf); \
+				if (system(sysbuf)) /* don't care */; \
 				fflush(stdout); \
 				free(sysbuf); \
 			} \
@@ -688,7 +715,7 @@
 	int fd;
 	char *strs;
 	static char buf[__PAX_UTILS_PATH_MAX] = "";
-	const char cachefile[] = "/etc/ld.so.cache";
+	const char *cachefile = root_rel_path("/etc/ld.so.cache");
 	struct stat st;
 
 	typedef struct {
@@ -709,10 +736,10 @@
 		return NULL;
 
 	if (ldcache == NULL) {
-		if (stat(cachefile, &st))
+		if (fstatat(root_fd, cachefile, &st, 0))
 			return NULL;
 
-		fd = open(cachefile, O_RDONLY);
+		fd = openat(root_fd, cachefile, O_RDONLY);
 		if (fd == -1)
 			return NULL;
 
@@ -1482,7 +1509,7 @@
 	return 0;
 }
 /* scan a file which may be an elf or an archive or some other magical beast */
-static int scanelf_file(const char *filename, const struct stat *st_cache)
+static int scanelf_fileat(int dir_fd, const char *filename, const struct stat *st_cache)
 {
 	const struct stat *st = st_cache;
 	struct stat symlink_st;
@@ -1490,8 +1517,9 @@
 
 	/* always handle regular files and handle symlinked files if no -y */
 	if (S_ISLNK(st->st_mode)) {
-		if (!scan_symlink) return 1;
-		stat(filename, &symlink_st);
+		if (!scan_symlink)
+			return 1;
+		fstatat(dir_fd, filename, &symlink_st, 0);
 		st = &symlink_st;
 	}
 
@@ -1504,81 +1532,88 @@
 		if ((st->st_mode | match_perms) != st->st_mode)
 			return 1;
 	}
-	if ((fd=open(filename, (fix_elf ? O_RDWR : O_RDONLY))) == -1)
+	fd = openat(dir_fd, filename, (fix_elf ? O_RDWR : O_RDONLY) | O_CLOEXEC);
+	if (fd == -1)
 		return 1;
 
 	if (scanelf_elf(filename, fd, st->st_size) == 1 && scan_archives)
 		/* if it isn't an ELF, maybe it's an .a archive */
 		scanelf_archive(filename, fd, st->st_size);
 
+	/* XXX: unreadelf() implicitly closes its fd */
 	close(fd);
 	return 0;
 }
 
-static const char *maybe_add_root(const char *fname, char *buf)
-{
-	if (root && strncmp(fname, root, strlen(root))) {
-		strcpy(buf, root);
-		strncat(buf, fname, __PAX_UTILS_PATH_MAX - strlen(root) - 1);
-		fname = buf;
-	}
-	return fname;
-}
-
 /* scan a directory for ET_EXEC files and print when we find one */
-static int scanelf_dir(const char *path)
+static int scanelf_dirat(int dir_fd, const char *path)
 {
 	register DIR *dir;
 	register struct dirent *dentry;
 	struct stat st_top, st;
-	char buf[__PAX_UTILS_PATH_MAX];
-	char _path[__PAX_UTILS_PATH_MAX];
+	char buf[__PAX_UTILS_PATH_MAX], *subpath;
 	size_t pathlen = 0, len = 0;
 	int ret = 0;
-
-	path = maybe_add_root(path, _path);
+	int subdir_fd;
 
 	/* make sure path exists */
-	if (lstat(path, &st_top) == -1) {
+	if (fstatat(dir_fd, path, &st_top, AT_SYMLINK_NOFOLLOW) == -1) {
 		if (be_verbose > 2) printf("%s: does not exist\n", path);
 		return 1;
 	}
 
 	/* ok, if it isn't a directory, assume we can open it */
-	if (!S_ISDIR(st_top.st_mode)) {
-		return scanelf_file(path, &st_top);
-	}
+	if (!S_ISDIR(st_top.st_mode))
+		return scanelf_fileat(dir_fd, path, &st_top);
 
 	/* now scan the dir looking for fun stuff */
-	if ((dir = opendir(path)) == NULL) {
+	subdir_fd = openat(dir_fd, path, O_RDONLY|O_CLOEXEC);
+	if (subdir_fd == -1)
+		dir = NULL;
+	else
+		dir = fdopendir(subdir_fd);
+	if (dir == NULL) {
+		if (subdir_fd != -1)
+			close(subdir_fd);
 		warnf("could not opendir %s: %s", path, strerror(errno));
 		return 1;
 	}
 	if (be_verbose > 1) printf("%s: scanning dir\n", path);
 
-	pathlen = strlen(path);
+	subpath = stpcpy(buf, path);
+	*subpath++ = '/';
+	pathlen = subpath - buf;
 	while ((dentry = readdir(dir))) {
 		if (!strcmp(dentry->d_name, ".") || !strcmp(dentry->d_name, ".."))
 			continue;
-		len = (pathlen + 1 + strlen(dentry->d_name) + 1);
-		if (len >= sizeof(buf)) {
-			warnf("Skipping '%s': len > sizeof(buf); %lu > %lu\n", path,
-			      (unsigned long)len, (unsigned long)sizeof(buf));
+
+		if (fstatat(subdir_fd, dentry->d_name, &st, AT_SYMLINK_NOFOLLOW) == -1)
+			continue;
+
+		len = strlen(dentry->d_name);
+		if (len + pathlen + 1 >= sizeof(buf)) {
+			warnf("Skipping '%s%s': len > sizeof(buf); %zu > %zu\n",
+			      path, dentry->d_name, len + pathlen + 1, sizeof(buf));
 			continue;
 		}
-		snprintf(buf, sizeof(buf), "%s%s%s", path, (path[pathlen-1] == '/') ? "" : "/", dentry->d_name);
-		if (lstat(buf, &st) != -1) {
-			if (S_ISREG(st.st_mode))
-				ret = scanelf_file(buf, &st);
-			else if (dir_recurse && S_ISDIR(st.st_mode)) {
-				if (dir_crossmount || (st_top.st_dev == st.st_dev))
-					ret = scanelf_dir(buf);
-			}
+		memcpy(subpath, dentry->d_name, len);
+		subpath[len] = '\0';
+
+		if (S_ISREG(st.st_mode))
+			ret = scanelf_fileat(dir_fd, buf, &st);
+		else if (dir_recurse && S_ISDIR(st.st_mode)) {
+			if (dir_crossmount || (st_top.st_dev == st.st_dev))
+				ret = scanelf_dirat(dir_fd, buf);
 		}
 	}
 	closedir(dir);
+
 	return ret;
 }
+static int scanelf_dir(const char *path)
+{
+	return scanelf_dirat(root_fd, root_rel_path(path));
+}
 
 static int scanelf_from_file(const char *filename)
 {
@@ -1616,11 +1651,10 @@
 	FILE *fp = NULL;
 	char *p, *path;
 	size_t len;
-	char _fname[__PAX_UTILS_PATH_MAX];
+	int curr_fd = -1;
 
-	fname = maybe_add_root(fname, _fname);
-
-	if ((fp = fopen(fname, "r")) == NULL)
+	fp = fopenat_r(root_fd, root_rel_path(fname));
+	if (fp == NULL)
 		return i;
 
 	path = NULL;
@@ -1635,16 +1669,21 @@
 		if ((memcmp(path, "include", 7) == 0) && isblank(path[7])) {
 			glob_t gl;
 			size_t x;
-			char gpath[__PAX_UTILS_PATH_MAX];
-
-			memset(gpath, 0, sizeof(gpath));
-			if (root)
-				strcpy(gpath, root);
+			const char *gpath;
 
+			/* re-use existing path buffer ... need to be creative */
 			if (path[8] != '/')
-				snprintf(gpath+strlen(gpath), sizeof(gpath)-strlen(gpath), "/etc/%s", &path[8]);
+				gpath = memcpy(path + 3, "/etc/", 5);
 			else
-				strncpy(gpath+strlen(gpath), &path[8], sizeof(gpath)-strlen(gpath));
+				gpath = path + 8;
+			if (root_fd != AT_FDCWD) {
+				if (curr_fd == -1) {
+					curr_fd = open(".", O_RDONLY|O_CLOEXEC);
+					if (fchdir(root_fd))
+						errp("unable to change to root dir");
+				}
+				gpath = root_rel_path(gpath);
+			}
 
 			if (glob(gpath, 0, NULL, &gl) == 0) {
 				for (x = 0; x < gl.gl_pathc; ++x) {
@@ -1654,8 +1693,10 @@
 					i = load_ld_cache_config(i, gl.gl_pathv[x]);
 				}
 				globfree(&gl);
-				continue;
 			}
+
+			/* failed globs are ignored by glibc */
+			continue;
 		}
 
 		if (*path != '/')
@@ -1667,6 +1708,12 @@
 
 	fclose(fp);
 
+	if (curr_fd != -1) {
+		if (fchdir(curr_fd))
+			/* don't care */;
+		close(curr_fd);
+	}
+
 	return i;
 }
 
@@ -1677,11 +1724,9 @@
 	FILE *fp = NULL;
 	char *b = NULL, *p;
 	struct elfhints_hdr hdr;
-	char _fname[__PAX_UTILS_PATH_MAX];
-
-	fname = maybe_add_root(fname, _fname);
 
-	if ((fp = fopen(fname, "r")) == NULL)
+	fp = fopenat_r(root_fd, root_rel_path(fname));
+	if (fp == NULL)
 		return i;
 
 	if (fread(&hdr, 1, sizeof(hdr), fp) != sizeof(hdr) ||
@@ -2015,7 +2060,9 @@
 		case 'I': show_osabi = 1; break;
 		case 'Y': show_eabi = 1; break;
 		case 128:
-			root = optarg;
+			root_fd = open(optarg, O_RDONLY|O_CLOEXEC);
+			if (root_fd == -1)
+				err("Could not open root: %s", optarg);
 			break;
 		case ':':
 			err("Option '%c' is missing parameter", optopt);
@@ -2194,7 +2241,7 @@
 #ifdef __PAX_UTILS_CLEANUP
 	cleanup();
 	warn("The calls to add/delete heap should be off:\n"
-	     "\t- 1 due to the out_buffer not being freed in scanelf_file()\n"
+	     "\t- 1 due to the out_buffer not being freed in scanelf_fileat()\n"
 	     "\t- 1 per QA_TEXTRELS/QA_EXECSTACK/QA_WX_LOAD");
 #endif
 	return ret;






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2011-10-13  4:49 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2011-10-13  4:49 UTC (permalink / raw
  To: gentoo-commits

vapier      11/10/13 04:49:30

  Modified:             scanelf.c
  Log:
  scanelf: support scanning for strings in ELFs that lack section headers by looking up the string tables via dynamic tags

Revision  Changes    Path
1.234                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.234&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.234&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.233&r2=1.234

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.233
retrieving revision 1.234
diff -u -r1.233 -r1.234
--- scanelf.c	3 Oct 2011 16:19:18 -0000	1.233
+++ scanelf.c	13 Oct 2011 04:49:30 -0000	1.234
@@ -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.233 2011/10/03 16:19:18 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.234 2011/10/13 04:49:30 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.233 2011/10/03 16:19:18 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.234 2011/10/13 04:49:30 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -143,7 +143,7 @@
 }
 
 /* sub-funcs for scanelf_fileat() */
-static void scanelf_file_get_symtabs(elfobj *elf, void **sym, void **tab)
+static void scanelf_file_get_symtabs(elfobj *elf, void **sym, void **str)
 {
 	/* find the best SHT_DYNSYM and SHT_STRTAB sections */
 
@@ -165,12 +165,103 @@
 	if (strtab && dynstr) { \
 		Elf ## B ## _Shdr *estrtab = strtab; \
 		Elf ## B ## _Shdr *edynstr = dynstr; \
-		*tab = (EGET(estrtab->sh_size) > EGET(edynstr->sh_size)) ? strtab : dynstr; \
+		*str = (EGET(estrtab->sh_size) > EGET(edynstr->sh_size)) ? strtab : dynstr; \
 	} else \
-		*tab = strtab ? strtab : dynstr; \
+		*str = strtab ? strtab : dynstr; \
 	}
 	GET_SYMTABS(32)
 	GET_SYMTABS(64)
+
+	if (*sym && *str)
+		return;
+
+	/*
+	 * damn, they're really going to make us work for it huh?
+	 * reconstruct the section header info out of the dynamic
+	 * tags so we can see what symbols this guy uses at runtime.
+	 */
+#define GET_SYMTABS_DT(B) \
+	if (elf->elf_class == ELFCLASS ## B) { \
+	size_t i; \
+	static Elf ## B ## _Shdr sym_shdr, str_shdr; \
+	Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
+	Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \
+	Elf ## B ## _Addr vsym, vstr, vhash, vgnu_hash; \
+	Elf ## B ## _Dyn *dyn; \
+	Elf ## B ## _Off offset; \
+	\
+	/* lookup symbols used at runtime with DT_SYMTAB / DT_STRTAB */ \
+	vsym = vstr = vhash = vgnu_hash = 0; \
+	memset(&sym_shdr, 0, sizeof(sym_shdr)); \
+	memset(&str_shdr, 0, sizeof(str_shdr)); \
+	for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
+		if (EGET(phdr[i].p_type) != PT_DYNAMIC) \
+			continue; \
+		\
+		offset = EGET(phdr[i].p_offset); \
+		if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) \
+			continue; \
+		\
+		dyn = DYN ## B (elf->vdata + offset); \
+		while (EGET(dyn->d_tag) != DT_NULL) { \
+			switch (EGET(dyn->d_tag)) { \
+			case DT_SYMTAB:   vsym = EGET(dyn->d_un.d_val); break; \
+			case DT_SYMENT:   sym_shdr.sh_entsize = dyn->d_un.d_val; break; \
+			case DT_STRTAB:   vstr = EGET(dyn->d_un.d_val); break; \
+			case DT_STRSZ:    str_shdr.sh_size = dyn->d_un.d_val; break; \
+			case DT_HASH:     vhash = EGET(dyn->d_un.d_val); break; \
+			/*case DT_GNU_HASH: vgnu_hash = EGET(dyn->d_un.d_val); break;*/ \
+			} \
+			++dyn; \
+		} \
+		if (vsym && vstr) \
+			break; \
+	} \
+	if (!vsym || !vstr || !(vhash || vgnu_hash)) \
+		return; \
+	\
+	/* calc offset into the ELF by finding the load addr of the syms */ \
+	for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
+		Elf ## B ## _Addr vaddr = EGET(phdr[i].p_vaddr); \
+		Elf ## B ## _Addr filesz = EGET(phdr[i].p_filesz); \
+		offset = EGET(phdr[i].p_offset); \
+		\
+		if (EGET(phdr[i].p_type) != PT_LOAD) \
+			continue; \
+		\
+		if (vhash >= vaddr && vhash < vaddr + filesz) { \
+			/* Scan the hash table to see how many entries we have */ \
+			Elf32_Word max_sym_idx = 0; \
+			Elf32_Word *hashtbl = elf->vdata + offset + (vhash - vaddr); \
+			Elf32_Word b, nbuckets = EGET(hashtbl[0]); \
+			Elf32_Word nchains = EGET(hashtbl[1]); \
+			Elf32_Word *buckets = &hashtbl[2]; \
+			Elf32_Word *chains = &buckets[nbuckets]; \
+			Elf32_Word sym_idx; \
+			\
+			for (b = 0; b < nbuckets; ++b) { \
+				if (!buckets[b]) \
+					continue; \
+				for (sym_idx = buckets[b]; sym_idx < nchains && sym_idx; sym_idx = chains[sym_idx]) \
+					if (max_sym_idx < sym_idx) \
+						max_sym_idx = sym_idx; \
+			} \
+			ESET(sym_shdr.sh_size, sym_shdr.sh_entsize * max_sym_idx); \
+		} \
+		\
+		if (vsym >= vaddr && vsym < vaddr + filesz) { \
+			ESET(sym_shdr.sh_offset, offset + (vsym - vaddr)); \
+			*sym = &sym_shdr; \
+		} \
+		\
+		if (vstr >= vaddr && vstr < vaddr + filesz) { \
+			ESET(str_shdr.sh_offset, offset + (vstr - vaddr)); \
+			*str = &str_shdr; \
+		} \
+	} \
+	}
+	GET_SYMTABS_DT(32)
+	GET_SYMTABS_DT(64)
 }
 
 static char *scanelf_file_pax(elfobj *elf, char *found_pax)
@@ -1183,7 +1274,6 @@
 
 static const char *scanelf_file_sym(elfobj *elf, char *found_sym)
 {
-	unsigned long i;
 	char *ret;
 	void *symtab_void, *strtab_void;
 
@@ -1198,7 +1288,7 @@
 		Elf ## B ## _Shdr *symtab = SHDR ## B (symtab_void); \
 		Elf ## B ## _Shdr *strtab = SHDR ## B (strtab_void); \
 		Elf ## B ## _Sym *sym = SYM ## B (elf->vdata + EGET(symtab->sh_offset)); \
-		unsigned long cnt = EGET(symtab->sh_entsize); \
+		Elf ## B ## _Word i, cnt = EGET(symtab->sh_entsize); \
 		char *symname; \
 		size_t ret_len = 0; \
 		if (cnt) \
@@ -1225,7 +1315,8 @@
 			                          EGET(sym->st_size)); \
 			} \
 			++sym; \
-		} }
+		} \
+		}
 		FIND_SYM(32)
 		FIND_SYM(64)
 	}






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2011-12-13  5:12 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-13  5:12 UTC (permalink / raw
  To: gentoo-commits

vapier      11/12/13 05:12:14

  Modified:             scanelf.c
  Log:
  optimize fd closing when scanning ELFs to avoid double closing it

Revision  Changes    Path
1.235                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.235&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.235&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.234&r2=1.235

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.234
retrieving revision 1.235
diff -u -r1.234 -r1.235
--- scanelf.c	13 Oct 2011 04:49:30 -0000	1.234
+++ scanelf.c	13 Dec 2011 05:12:14 -0000	1.235
@@ -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.234 2011/10/13 04:49:30 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.235 2011/12/13 05:12:14 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.234 2011/10/13 04:49:30 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.235 2011/12/13 05:12:14 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -1536,7 +1536,7 @@
 	/* verify this is real ELF */
 	if ((elf = _readelf_fd(filename, fd, len, !fix_elf)) == NULL) {
 		if (be_verbose > 2) printf("%s: not an ELF\n", filename);
-		return ret;
+		return 2;
 	}
 	switch (match_bits) {
 		case 32:
@@ -1627,12 +1627,18 @@
 	if (fd == -1)
 		return 1;
 
-	if (scanelf_elf(filename, fd, st->st_size) == 1 && scan_archives)
+	if (scanelf_elf(filename, fd, st->st_size) == 2) {
 		/* if it isn't an ELF, maybe it's an .a archive */
-		scanelf_archive(filename, fd, st->st_size);
+		if (scan_archives)
+			scanelf_archive(filename, fd, st->st_size);
+
+		/*
+		 * unreadelf() implicitly closes its fd, so only close it
+		 * when we are returning it in the non-ELF case
+		 */
+		close(fd);
+	}
 
-	/* XXX: unreadelf() implicitly closes its fd */
-	close(fd);
 	return 0;
 }
 






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2011-12-21 17:34 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-21 17:34 UTC (permalink / raw
  To: gentoo-commits

vapier      11/12/21 17:34:12

  Modified:             scanelf.c
  Log:
  support ! negation with the -N (SONAME) operator

Revision  Changes    Path
1.236                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.236&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.236&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.235&r2=1.236

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.235
retrieving revision 1.236
diff -u -r1.235 -r1.236
--- scanelf.c	13 Dec 2011 05:12:14 -0000	1.235
+++ scanelf.c	21 Dec 2011 17:34:12 -0000	1.236
@@ -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.235 2011/12/13 05:12:14 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.236 2011/12/21 17:34:12 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.235 2011/12/13 05:12:14 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.236 2011/12/21 17:34:12 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -971,9 +971,13 @@
 						size_t n; \
 						const char *find_lib_name; \
 						\
-						array_for_each(find_lib_arr, n, find_lib_name) \
-							if (!strcmp(find_lib_name, needed)) \
+						array_for_each(find_lib_arr, n, find_lib_name) { \
+							int invert = 1; \
+							if (find_lib_name[0] == '!') \
+								invert = 0, ++find_lib_name; \
+							if (!strcmp(find_lib_name, needed) == invert) \
 								++matched; \
+						} \
 						\
 						if (matched == array_cnt(find_lib_arr)) { \
 							*found_lib = 1; \






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2011-12-21 22:00 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-21 22:00 UTC (permalink / raw
  To: gentoo-commits

vapier      11/12/21 22:00:58

  Modified:             scanelf.c
  Log:
  use warnfp/errp rather than calling strerror(errno) ourselves

Revision  Changes    Path
1.237                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.237&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.237&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.236&r2=1.237

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.236
retrieving revision 1.237
diff -u -r1.236 -r1.237
--- scanelf.c	21 Dec 2011 17:34:12 -0000	1.236
+++ scanelf.c	21 Dec 2011 22:00:58 -0000	1.237
@@ -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.236 2011/12/21 17:34:12 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.237 2011/12/21 22:00:58 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.236 2011/12/21 17:34:12 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.237 2011/12/21 22:00:58 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -1676,7 +1676,7 @@
 	if (dir == NULL) {
 		if (subdir_fd != -1)
 			close(subdir_fd);
-		warnf("could not opendir %s: %s", path, strerror(errno));
+		warnfp("could not opendir(%s)", path);
 		return 1;
 	}
 	if (be_verbose > 1) printf("%s: scanning dir\n", path);
@@ -2071,7 +2071,7 @@
 			break;
 		case 'o': {
 			if (freopen(optarg, "w", stdout) == NULL)
-				err("Could not open output stream '%s': %s", optarg, strerror(errno));
+				errp("Could not freopen(%s)", optarg);
 			break;
 		}
 		case 'k':






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2011-12-21 22:17 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2011-12-21 22:17 UTC (permalink / raw
  To: gentoo-commits

vapier      11/12/21 22:17:36

  Modified:             scanelf.c
  Log:
  fix typo in symbol description

Revision  Changes    Path
1.238                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.238&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.238&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.237&r2=1.238

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.237
retrieving revision 1.238
diff -u -r1.237 -r1.238
--- scanelf.c	21 Dec 2011 22:00:58 -0000	1.237
+++ scanelf.c	21 Dec 2011 22:17:36 -0000	1.238
@@ -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.237 2011/12/21 22:00:58 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.238 2011/12/21 22:17:36 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.237 2011/12/21 22:00:58 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.238 2011/12/21 22:17:36 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -1122,7 +1122,7 @@
  *    filters.  There are groups of modifiers.  If you don't specify a member
  *    of a group, then all types in that group are matched.  The current
  *    groups and their types are:
- *        STT group: STT_NOTYPE:n STT_OBJECT:o STT_FUNC:f SST_FILE:F
+ *        STT group: STT_NOTYPE:n STT_OBJECT:o STT_FUNC:f STT_FILE:F
  *        STB group: STB_LOCAL:l STB_GLOBAL:g STB_WEAK:w
  *        SHN group: SHN_UNDEF:u SHN_ABS:a SHN_COMMON:c {defined}:d
  *    The "defined" value in the SHN group does not correspond to a SHN_xxx define.






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2012-01-23 22:28 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2012-01-23 22:28 UTC (permalink / raw
  To: gentoo-commits

vapier      12/01/23 22:28:17

  Modified:             scanelf.c
  Log:
  clarify --ldcache help option

Revision  Changes    Path
1.239                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.239&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.239&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.238&r2=1.239

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.238
retrieving revision 1.239
diff -u -r1.238 -r1.239
--- scanelf.c	21 Dec 2011 22:17:36 -0000	1.238
+++ scanelf.c	23 Jan 2012 22:28:17 -0000	1.239
@@ -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.238 2011/12/21 22:17:36 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.239 2012/01/23 22:28:17 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.238 2011/12/21 22:17:36 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.239 2012/01/23 22:28:17 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -1965,7 +1965,7 @@
 	"Don't recursively cross mount points",
 	"Don't scan symlinks",
 	"Scan archives (.a files)",
-	"Utilize ld.so.cache information (use with -r/-n)",
+	"Utilize ld.so.cache to show full path (use with -r/-n)",
 	"Try and 'fix' bad things (use with -r/-e)",
 	"Sets EI_PAX/PT_PAX_FLAGS to <arg> (use with -Xx)\n",
 	"Print PaX markings",






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2012-01-23 23:48 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2012-01-23 23:48 UTC (permalink / raw
  To: gentoo-commits

vapier      12/01/23 23:48:54

  Modified:             scanelf.c
  Log:
  add --use-ldpath option that considers ld.so.conf when outputting full paths for %n

Revision  Changes    Path
1.240                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.240&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.240&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.239&r2=1.240

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.239
retrieving revision 1.240
diff -u -r1.239 -r1.240
--- scanelf.c	23 Jan 2012 22:28:17 -0000	1.239
+++ scanelf.c	23 Jan 2012 23:48:54 -0000	1.240
@@ -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.239 2012/01/23 22:28:17 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.240 2012/01/23 23:48:54 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.239 2012/01/23 22:28:17 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.240 2012/01/23 23:48:54 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -55,6 +55,7 @@
 static char fix_elf = 0;
 static char g_match = 0;
 static char use_ldcache = 0;
+static char use_ldpath = 0;
 
 static char **qa_textrels = NULL;
 static char **qa_execstack = NULL;
@@ -801,7 +802,7 @@
 
 #if defined(__GLIBC__) || defined(__UCLIBC__)
 
-static char *lookup_cache_lib(elfobj *elf, char *fname)
+static char *lookup_cache_lib(elfobj *elf, const char *fname)
 {
 	int fd;
 	char *strs;
@@ -879,7 +880,7 @@
 }
 
 #elif defined(__NetBSD__)
-static char *lookup_cache_lib(elfobj *elf, char *fname)
+static char *lookup_cache_lib(elfobj *elf, const char *fname)
 {
 	static char buf[__PAX_UTILS_PATH_MAX] = "";
 	static struct stat st;
@@ -908,12 +909,27 @@
 #ifdef __ELF__
 #warning Cache support not implemented for your target
 #endif
-static char *lookup_cache_lib(elfobj *elf, char *fname)
+static char *lookup_cache_lib(elfobj *elf, const char *fname)
 {
 	return NULL;
 }
 #endif
 
+static char *lookup_config_lib(elfobj *elf, char *fname)
+{
+	static char buf[__PAX_UTILS_PATH_MAX] = "";
+	const char *ldpath;
+	size_t n;
+
+	array_for_each(ldpaths, n, ldpath) {
+		snprintf(buf, sizeof(buf), "%s/%s", root_rel_path(ldpath), fname);
+		if (faccessat(root_fd, buf, F_OK, AT_SYMLINK_NOFOLLOW) == 0)
+			return buf;
+	}
+
+	return NULL;
+}
+
 static const char *scanelf_file_needed_lib(elfobj *elf, char *found_needed, char *found_lib, int op, char **ret, size_t *ret_len)
 {
 	unsigned long i;
@@ -960,9 +976,13 @@
 						/* -n -> print all entries */ \
 						if (!be_wewy_wewy_quiet) { \
 							if (*found_needed) xchrcat(ret, ',', ret_len); \
-							if (use_ldcache) \
+							if (use_ldpath) { \
+								if ((p = lookup_config_lib(elf, needed)) != NULL) \
+									needed = p; \
+							} else if (use_ldcache) { \
 								if ((p = lookup_cache_lib(elf, needed)) != NULL) \
 									needed = p; \
+							} \
 							xstrcat(ret, needed, ret_len); \
 						} \
 						*found_needed = 1; \
@@ -1421,6 +1441,7 @@
 			case 't': prints("TEXTREL "); break;
 			case 'r': prints("RPATH "); break;
 			case 'M': prints("CLASS "); break;
+			case 'l':
 			case 'n': prints("NEEDED "); break;
 			case 'i': prints("INTERP "); break;
 			case 'b': prints("BIND "); break;
@@ -1747,7 +1768,7 @@
 
 #if defined(__GLIBC__) || defined(__UCLIBC__) || defined(__NetBSD__)
 
-static int load_ld_cache_config(int i, const char *fname)
+static int _load_ld_cache_config(const char *fname)
 {
 	FILE *fp = NULL;
 	char *p, *path;
@@ -1756,7 +1777,7 @@
 
 	fp = fopenat_r(root_fd, root_rel_path(fname));
 	if (fp == NULL)
-		return i;
+		return -1;
 
 	path = NULL;
 	len = 0;
@@ -1791,7 +1812,7 @@
 					/* try to avoid direct loops */
 					if (strcmp(gl.gl_pathv[x], fname) == 0)
 						continue;
-					i = load_ld_cache_config(i, gl.gl_pathv[x]);
+					_load_ld_cache_config(gl.gl_pathv[x]);
 				}
 				globfree(&gl);
 			}
@@ -1815,12 +1836,12 @@
 		close(curr_fd);
 	}
 
-	return i;
+	return 0;
 }
 
 #elif defined(__FreeBSD__) || defined(__DragonFly__)
 
-static int load_ld_cache_config(int i, const char *fname)
+static int _load_ld_cache_config(const char *fname)
 {
 	FILE *fp = NULL;
 	char *b = NULL, *p;
@@ -1828,21 +1849,21 @@
 
 	fp = fopenat_r(root_fd, root_rel_path(fname));
 	if (fp == NULL)
-		return i;
+		return -1;
 
 	if (fread(&hdr, 1, sizeof(hdr), fp) != sizeof(hdr) ||
 	    hdr.magic != ELFHINTS_MAGIC || hdr.version != 1 ||
 	    fseek(fp, hdr.strtab + hdr.dirlist, SEEK_SET) == -1)
 	{
 		fclose(fp);
-		return i;
+		return -1;
 	}
 
 	b = xmalloc(hdr.dirlistlen + 1);
 	if (fread(b, 1, hdr.dirlistlen+1, fp) != hdr.dirlistlen+1) {
 		fclose(fp);
 		free(b);
-		return i;
+		return -1;
 	}
 
 	while ((p = strsep(&b, ":"))) {
@@ -1853,43 +1874,49 @@
 
 	free(b);
 	fclose(fp);
-	return i;
+	return 0;
 }
 
 #else
 #ifdef __ELF__
 #warning Cache config support not implemented for your target
 #endif
-static int load_ld_cache_config(int i, const char *fname)
+static int _load_ld_cache_config(const char *fname)
 {
 	return 0;
 }
 #endif
 
-/* scan /etc/ld.so.conf for paths */
-static void scanelf_ldpath(void)
+static void load_ld_cache_config(const char *fname)
 {
-	char scan_l, scan_ul, scan_ull;
+	bool scan_l, scan_ul, scan_ull;
 	size_t n;
 	const char *ldpath;
-	int i = 0;
 
-	if (array_cnt(ldpaths) == 0)
-		err("Unable to load any paths from ld.so.conf");
+	_load_ld_cache_config(fname);
 
-	scan_l = scan_ul = scan_ull = 0;
-
-	array_for_each(ldpaths, n, ldpath) {
-		if (!scan_l   && !strcmp(ldpath, "/lib"))           scan_l   = 1;
-		if (!scan_ul  && !strcmp(ldpath, "/usr/lib"))       scan_ul  = 1;
-		if (!scan_ull && !strcmp(ldpath, "/usr/local/lib")) scan_ull = 1;
-		scanelf_dir(ldpath);
-		++i;
+	scan_l = scan_ul = scan_ull = false;
+	if (array_cnt(ldpaths)) {
+		array_for_each(ldpaths, n, ldpath) {
+			if (!scan_l   && !strcmp(ldpath, "/lib"))           scan_l   = true;
+			if (!scan_ul  && !strcmp(ldpath, "/usr/lib"))       scan_ul  = true;
+			if (!scan_ull && !strcmp(ldpath, "/usr/local/lib")) scan_ull = true;
+		}
 	}
 
-	if (!scan_l)   scanelf_dir("/lib");
-	if (!scan_ul)  scanelf_dir("/usr/lib");
-	if (!scan_ull) scanelf_dir("/usr/local/lib");
+	if (!scan_l)   xarraypush_str(ldpaths, "/lib");
+	if (!scan_ul)  xarraypush_str(ldpaths, "/usr/lib");
+	if (!scan_ull) xarraypush_str(ldpaths, "/usr/local/lib");
+}
+
+/* scan /etc/ld.so.conf for paths */
+static void scanelf_ldpath(void)
+{
+	size_t n;
+	const char *ldpath;
+
+	array_for_each(ldpaths, n, ldpath)
+		scanelf_dir(ldpath);
 }
 
 /* scan env PATH for paths */
@@ -1916,6 +1943,7 @@
 static struct option const long_opts[] = {
 	{"path",      no_argument, NULL, 'p'},
 	{"ldpath",    no_argument, NULL, 'l'},
+	{"use-ldpath",no_argument, NULL, 129},
 	{"root",       a_argument, NULL, 128},
 	{"recursive", no_argument, NULL, 'R'},
 	{"mount",     no_argument, NULL, 'm'},
@@ -1960,6 +1988,7 @@
 static const char * const opts_help[] = {
 	"Scan all directories in PATH environment",
 	"Scan all directories in /etc/ld.so.conf",
+	"Use ld.so.conf to show full path (use with -r/-n)",
 	"Root directory (use with -l or -p)",
 	"Scan directories recursively",
 	"Don't recursively cross mount points",
@@ -2037,6 +2066,7 @@
 	int i;
 	const char *from_file = NULL;
 	int ret = 0;
+	char load_cache_config = 0;
 
 	opterr = 0;
 	while ((i=getopt_long(argc, argv, PARSE_FLAGS, long_opts, NULL)) != -1) {
@@ -2135,12 +2165,12 @@
 		}
 		case 'Z': show_size = 1; break;
 		case 'g': g_match = 1; break;
-		case 'L': use_ldcache = 1; break;
+		case 'L': load_cache_config = use_ldcache = 1; break;
 		case 'y': scan_symlink = 0; break;
 		case 'A': scan_archives = 1; break;
 		case 'C': color_init(true); break;
 		case 'B': show_banner = 0; break;
-		case 'l': scan_ldpath = 1; break;
+		case 'l': load_cache_config = scan_ldpath = 1; break;
 		case 'p': scan_envpath = 1; break;
 		case 'R': dir_recurse = 1; break;
 		case 'm': dir_crossmount = 0; break;
@@ -2165,6 +2195,7 @@
 			if (root_fd == -1)
 				err("Could not open root: %s", optarg);
 			break;
+		case 129: load_cache_config = use_ldpath = 1; break;
 		case ':':
 			err("Option '%c' is missing parameter", optopt);
 		case '?':
@@ -2217,7 +2248,7 @@
 			case 'S': show_soname = 1; break;
 			case 'T': show_textrels = 1; break;
 			default:
-				err("Invalid format specifier '%c' (byte %i)",
+				err("invalid format specifier '%c' (byte %i)",
 				    out_format[i], i+1);
 			}
 		}
@@ -2250,8 +2281,8 @@
 	if (be_verbose > 2) printf("Format: %s\n", out_format);
 
 	/* now lets actually do the scanning */
-	if (scan_ldpath || use_ldcache)
-		load_ld_cache_config(0, __PAX_UTILS_DEFAULT_LD_CACHE_CONFIG);
+	if (load_cache_config)
+		load_ld_cache_config(__PAX_UTILS_DEFAULT_LD_CACHE_CONFIG);
 	if (scan_ldpath) scanelf_ldpath();
 	if (scan_envpath) scanelf_envpath();
 	if (!from_file && optind == argc && ttyname(0) == NULL && !scan_ldpath && !scan_envpath)






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2012-01-25  1:58 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2012-01-25  1:58 UTC (permalink / raw
  To: gentoo-commits

vapier      12/01/25 01:58:29

  Modified:             scanelf.c
  Log:
  fix help output to properly handle non-letter opts all the time

Revision  Changes    Path
1.241                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.241&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.241&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.240&r2=1.241

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.240
retrieving revision 1.241
diff -u -r1.240 -r1.241
--- scanelf.c	23 Jan 2012 23:48:54 -0000	1.240
+++ scanelf.c	25 Jan 2012 01:58:29 -0000	1.241
@@ -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.240 2012/01/23 23:48:54 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.241 2012/01/25 01:58:29 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.240 2012/01/23 23:48:54 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.241 2012/01/25 01:58:29 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -2037,16 +2037,22 @@
 	printf("* Scan ELF binaries for stuff\n\n"
 	       "Usage: %s [options] <dir1/file1> [dir2 dirN file2 fileN ...]\n\n", argv0);
 	printf("Options: -[%s]\n", PARSE_FLAGS);
-	for (i = 0; long_opts[i].name; ++i)
+	for (i = 0; long_opts[i].name; ++i) {
+		/* first output the short flag if it has one */
+		if (long_opts[i].val > '~')
+			printf("      ");
+		else
+			printf("  -%c, ", long_opts[i].val);
+
+		/* then the long flag */
 		if (long_opts[i].has_arg == no_argument)
-			printf("  -%c, --%-14s* %s\n", long_opts[i].val,
-			       long_opts[i].name, opts_help[i]);
-		else if (long_opts[i].val > '~')
-			printf("      --%-7s <arg> * %s\n",
-			       long_opts[i].name, opts_help[i]);
+			printf("--%-14s", long_opts[i].name);
 		else
-			printf("  -%c, --%-7s <arg> * %s\n", long_opts[i].val,
-			       long_opts[i].name, opts_help[i]);
+			printf("--%-7s <arg> ", long_opts[i].name);
+
+		/* finally the help text */
+		printf("* %s\n", opts_help[i]);
+	}
 
 	puts("\nFor more information, see the scanelf(1) manpage");
 	exit(status);






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2012-04-29  5:41 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2012-04-29  5:41 UTC (permalink / raw
  To: gentoo-commits

vapier      12/04/29 05:41:14

  Modified:             scanelf.c
  Log:
  only append a slash if there isnt one already #404003 by Slawomir Nizio

Revision  Changes    Path
1.243                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.243&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.243&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.242&r2=1.243

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.242
retrieving revision 1.243
diff -u -r1.242 -r1.243
--- scanelf.c	28 Apr 2012 05:14:26 -0000	1.242
+++ scanelf.c	29 Apr 2012 05:41:14 -0000	1.243
@@ -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.242 2012/04/28 05:14:26 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.243 2012/04/29 05:41:14 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.242 2012/04/28 05:14:26 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.243 2012/04/29 05:41:14 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -1699,7 +1699,8 @@
 	if (be_verbose > 1) printf("%s: scanning dir\n", path);
 
 	subpath = stpcpy(buf, path);
-	*subpath++ = '/';
+	if (subpath[-1] != '/')
+		*subpath++ = '/';
 	pathlen = subpath - buf;
 	while ((dentry = readdir(dir))) {
 		if (!strcmp(dentry->d_name, ".") || !strcmp(dentry->d_name, ".."))






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2012-04-29  6:21 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2012-04-29  6:21 UTC (permalink / raw
  To: gentoo-commits

vapier      12/04/29 06:21:36

  Modified:             scanelf.c
  Log:
  when looking for symbol sections, ignore ones labeled NOBITS as that means they dont have any actual data (like in split debug files) #411023 by Mark

Revision  Changes    Path
1.244                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.244&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.244&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.243&r2=1.244

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.243
retrieving revision 1.244
diff -u -r1.243 -r1.244
--- scanelf.c	29 Apr 2012 05:41:14 -0000	1.243
+++ scanelf.c	29 Apr 2012 06:21:36 -0000	1.244
@@ -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.243 2012/04/29 05:41:14 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.244 2012/04/29 06:21:36 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.243 2012/04/29 05:41:14 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.244 2012/04/29 06:21:36 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -155,19 +155,35 @@
 	void *dynsym = elf_findsecbyname(elf, ".dynsym");
 	void *dynstr = elf_findsecbyname(elf, ".dynstr");
 
+	/*
+	 * If the sections are marked NOBITS, then they don't exist, so we just
+	 * skip them.  This let's us work sanely with splitdebug ELFs (rather
+	 * than spewing a lot of "corrupt ELF" messages later on).  In malformed
+	 * ELFs, the section might be wrongly set to NOBITS, but screw em.
+	 */
 #define GET_SYMTABS(B) \
 	if (elf->elf_class == ELFCLASS ## B) { \
-	if (symtab && dynsym) { \
-		Elf ## B ## _Shdr *esymtab = symtab; \
-		Elf ## B ## _Shdr *edynsym = dynsym; \
+	Elf ## B ## _Shdr *esymtab = symtab; \
+	Elf ## B ## _Shdr *estrtab = strtab; \
+	Elf ## B ## _Shdr *edynsym = dynsym; \
+	Elf ## B ## _Shdr *edynstr = dynstr; \
+	\
+	if (symtab && EGET(esymtab->sh_type) == SHT_NOBITS) \
+		symtab = NULL; \
+	if (dynsym && EGET(edynsym->sh_type) == SHT_NOBITS) \
+		dynsym = NULL; \
+	if (symtab && dynsym) \
 		*sym = (EGET(esymtab->sh_size) > EGET(edynsym->sh_size)) ? symtab : dynsym; \
-	} else \
+	else \
 		*sym = symtab ? symtab : dynsym; \
-	if (strtab && dynstr) { \
-		Elf ## B ## _Shdr *estrtab = strtab; \
-		Elf ## B ## _Shdr *edynstr = dynstr; \
+	\
+	if (strtab && EGET(estrtab->sh_type) == SHT_NOBITS) \
+		strtab = NULL; \
+	if (dynstr && EGET(edynstr->sh_type) == SHT_NOBITS) \
+		dynstr = NULL; \
+	if (strtab && dynstr) \
 		*str = (EGET(estrtab->sh_size) > EGET(edynstr->sh_size)) ? strtab : dynstr; \
-	} else \
+	else \
 		*str = strtab ? strtab : dynstr; \
 	}
 	GET_SYMTABS(32)






^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2012-08-04  6:08 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2012-08-04  6:08 UTC (permalink / raw
  To: gentoo-commits

vapier      12/08/04 06:08:25

  Modified:             scanelf.c
  Log:
  scanelf: add warnings when we cannot open an elf #427640 by Anthony Basile

Revision  Changes    Path
1.245                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.245&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.245&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.244&r2=1.245

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.244
retrieving revision 1.245
diff -u -r1.244 -r1.245
--- scanelf.c	29 Apr 2012 06:21:36 -0000	1.244
+++ scanelf.c	4 Aug 2012 06:08:25 -0000	1.245
@@ -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.244 2012/04/29 06:21:36 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.245 2012/08/04 06:08:25 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.244 2012/04/29 06:21:36 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.245 2012/08/04 06:08:25 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -1661,8 +1661,13 @@
 			return 1;
 	}
 	fd = openat(dir_fd, filename, (fix_elf ? O_RDWR : O_RDONLY) | O_CLOEXEC);
-	if (fd == -1)
+	if (fd == -1) {
+		if (fix_elf && errno == ETXTBSY)
+			warnp("%s: could not fix", filename);
+		else if (be_verbose > 2)
+			printf("%s: skipping file: %s\n", filename, strerror(errno));
 		return 1;
+	}
 
 	if (scanelf_elf(filename, fd, st->st_size) == 2) {
 		/* if it isn't an ELF, maybe it's an .a archive */





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2012-11-04  6:55 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-04  6:55 UTC (permalink / raw
  To: gentoo-commits

vapier      12/11/04 06:55:04

  Modified:             scanelf.c
  Log:
  scanelf: if people use -g twice, switch to case insensitive regexes #433425

Revision  Changes    Path
1.246                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.246&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.246&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.245&r2=1.246

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.245
retrieving revision 1.246
diff -u -r1.245 -r1.246
--- scanelf.c	4 Aug 2012 06:08:25 -0000	1.245
+++ scanelf.c	4 Nov 2012 06:55:04 -0000	1.246
@@ -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.245 2012/08/04 06:08:25 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.246 2012/11/04 06:55:04 vapier Exp $
  *
  * Copyright 2003-2007 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2007 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.245 2012/08/04 06:08:25 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.246 2012/11/04 06:55:04 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -127,14 +127,11 @@
 	if ((match == NULL) || (regex == NULL))
 		return EXIT_FAILURE;
 
-	if ((ret = regcomp(&preg, regex, cflags))) {
+	ret = regcomp(&preg, regex, cflags);
+	if (ret) {
 		char err[256];
-
-		if (regerror(ret, &preg, err, sizeof(err)))
-			fprintf(stderr, "regcomp failed: %s", err);
-		else
-			fprintf(stderr, "regcomp failed");
-
+		regerror(ret, &preg, err, sizeof(err));
+		warnf("regcomp failed: %s", err);
 		return EXIT_FAILURE;
 	}
 	ret = regexec(&preg, match, 0, NULL, 0);
@@ -1272,7 +1269,10 @@
 		} else {
 			if (g_match) {
 				/* regex match the symbol */
-				if (rematch(this_sym, symname, REG_EXTENDED) != 0)
+				int flags = REG_EXTENDED | REG_NOSUB;
+				if (g_match > 1)
+					flags |= REG_ICASE;
+				if (rematch(this_sym, symname, flags) != 0)
 					continue;
 
 			} else if (*this_sym) {
@@ -2026,7 +2026,7 @@
 	"Find a specified symbol",
 	"Find a specified section",
 	"Find a specified library",
-	"Use regex matching rather than string compare (use with -s)",
+	"Use regex rather than string compare (with -s); specify twice for case insensitive",
 	"Locate cause of TEXTREL",
 	"Print only ELF files matching etype ET_DYN,ET_EXEC ...",
 	"Print only ELF files matching numeric bits",
@@ -2188,7 +2188,7 @@
 			break;
 		}
 		case 'Z': show_size = 1; break;
-		case 'g': g_match = 1; break;
+		case 'g': ++g_match; break;
 		case 'L': load_cache_config = use_ldcache = 1; break;
 		case 'y': scan_symlink = 0; break;
 		case 'A': scan_archives = 1; break;





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2012-11-04  7:48 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-04  7:48 UTC (permalink / raw
  To: gentoo-commits

vapier      12/11/04 07:48:42

  Modified:             scanelf.c
  Log:
  scanelf: convert -s parsing to arrays and allow multiple -s options

Revision  Changes    Path
1.248                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.248&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.248&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.247&r2=1.248

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.247
retrieving revision 1.248
diff -u -r1.247 -r1.248
--- scanelf.c	4 Nov 2012 07:26:24 -0000	1.247
+++ scanelf.c	4 Nov 2012 07:48:42 -0000	1.248
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.247 2012/11/04 07:26:24 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.248 2012/11/04 07:48:42 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.247 2012/11/04 07:26:24 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.248 2012/11/04 07:48:42 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -46,6 +46,7 @@
 static char be_wewy_wewy_quiet = 0;
 static char be_semi_verbose = 0;
 static char *find_sym = NULL;
+static array_t _find_sym_arr = array_init_decl, *find_sym_arr = &_find_sym_arr;
 static char *find_lib = NULL;
 static array_t _find_lib_arr = array_init_decl, *find_lib_arr = &_find_lib_arr;
 static char *find_section = NULL;
@@ -1173,27 +1174,14 @@
 scanelf_match_symname(elfobj *elf, char *found_sym, char **ret, size_t *ret_len, const char *symname,
 	unsigned int stt, unsigned int stb, unsigned int shn, unsigned long size)
 {
-	char *this_sym, *next_sym, saved = saved;
+	const char *this_sym;
+	size_t n;
 
-	/* allow the user to specify a comma delimited list of symbols to search for */
-	next_sym = NULL;
-	do {
+	array_for_each(find_sym_arr, n, this_sym) {
 		bool inc_notype, inc_object, inc_func, inc_file,
 		     inc_local, inc_global, inc_weak,
 		     inc_def, inc_undef, inc_abs, inc_common;
 
-		if (next_sym) {
-			next_sym[-1] = saved;
-			this_sym = next_sym;
-		} else
-			this_sym = find_sym;
-		if ((next_sym = strchr(this_sym, ','))) {
-			/* make parsing easier by killing the comma temporarily */
-			saved = *next_sym;
-			*next_sym = '\0';
-			next_sym += 1;
-		}
-
 		/* symbol selection! */
 		inc_notype = inc_object = inc_func = inc_file = \
 		inc_local = inc_global = inc_weak = \
@@ -1298,14 +1286,12 @@
 
 			goto matched;
 		}
-	} while (next_sym);
+	}
 
 	return;
 
  matched:
 	*found_sym = 1;
-	if (next_sym)
-		next_sym[-1] = saved;
 }
 
 static const char *scanelf_file_sym(elfobj *elf, char *found_sym)
@@ -2132,8 +2118,12 @@
 			xarraypush_str(find_section_arr, optarg);
 			break;
 		case 's': {
-			if (find_sym) warn("You prob don't want to specify -s twice");
-			find_sym = optarg;
+			/* historically, this was comma delimited */
+			char *this_sym = strtok(optarg, ",");
+			while (this_sym) {
+				xarraypush_str(find_sym_arr, this_sym);
+				this_sym = strtok(NULL, ",");
+			}
 			break;
 		}
 		case 'N':
@@ -2231,6 +2221,8 @@
 	if (show_textrels && be_verbose)
 		has_objdump = bin_in_path("objdump");
 	/* flatten arrays for display */
+	if (array_cnt(find_sym_arr))
+		find_sym = array_flatten_str(find_sym_arr);
 	if (array_cnt(find_lib_arr))
 		find_lib = array_flatten_str(find_lib_arr);
 	if (array_cnt(find_section_arr))
@@ -2324,8 +2316,10 @@
 
 	/* clean up */
 	xarrayfree(ldpaths);
+	xarrayfree(find_sym_arr);
 	xarrayfree(find_lib_arr);
 	xarrayfree(find_section_arr);
+	free(find_sym);
 	free(find_lib);
 	free(find_section);
 





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2012-11-04  8:23 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-04  8:23 UTC (permalink / raw
  To: gentoo-commits

vapier      12/11/04 08:23:12

  Modified:             scanelf.c
  Log:
  scanelf: pre-compile all the regexes up front rather than everytime we try to match the symbol

Revision  Changes    Path
1.249                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.249&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.249&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.248&r2=1.249

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.248
retrieving revision 1.249
diff -u -r1.248 -r1.249
--- scanelf.c	4 Nov 2012 07:48:42 -0000	1.248
+++ scanelf.c	4 Nov 2012 08:23:12 -0000	1.249
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.248 2012/11/04 07:48:42 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.249 2012/11/04 08:23:12 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.248 2012/11/04 07:48:42 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.249 2012/11/04 08:23:12 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -47,6 +47,7 @@
 static char be_semi_verbose = 0;
 static char *find_sym = NULL;
 static array_t _find_sym_arr = array_init_decl, *find_sym_arr = &_find_sym_arr;
+static array_t _find_sym_regex_arr = array_init_decl, *find_sym_regex_arr = &_find_sym_regex_arr;
 static char *find_lib = NULL;
 static array_t _find_lib_arr = array_init_decl, *find_lib_arr = &_find_lib_arr;
 static char *find_section = NULL;
@@ -119,28 +120,6 @@
 	return path;
 }
 
-/* 1 on failure. 0 otherwise */
-static int rematch(const char *regex, const char *match, int cflags)
-{
-	regex_t preg;
-	int ret;
-
-	if ((match == NULL) || (regex == NULL))
-		return EXIT_FAILURE;
-
-	ret = regcomp(&preg, regex, cflags);
-	if (ret) {
-		char err[256];
-		regerror(ret, &preg, err, sizeof(err));
-		warnf("regcomp failed: %s", err);
-		return EXIT_FAILURE;
-	}
-	ret = regexec(&preg, match, 0, NULL, 0);
-	regfree(&preg);
-
-	return ret;
-}
-
 /* sub-funcs for scanelf_fileat() */
 static void scanelf_file_get_symtabs(elfobj *elf, void **sym, void **str)
 {
@@ -1257,10 +1236,7 @@
 		} else {
 			if (g_match) {
 				/* regex match the symbol */
-				int flags = REG_EXTENDED | REG_NOSUB;
-				if (g_match > 1)
-					flags |= REG_ICASE;
-				if (rematch(this_sym, symname, flags) != 0)
+				if (regexec(find_sym_regex_arr->eles[n], symname, 0, NULL, 0) == REG_NOMATCH)
 					continue;
 
 			} else if (*this_sym) {
@@ -2120,6 +2096,8 @@
 		case 's': {
 			/* historically, this was comma delimited */
 			char *this_sym = strtok(optarg, ",");
+			if (!this_sym)	/* edge case: -s '' */
+				xarraypush_str(find_sym_arr, "");
 			while (this_sym) {
 				xarraypush_str(find_sym_arr, this_sym);
 				this_sym = strtok(NULL, ",");
@@ -2220,6 +2198,40 @@
 	}
 	if (show_textrels && be_verbose)
 		has_objdump = bin_in_path("objdump");
+	/* precompile all the regexes */
+	if (g_match) {
+		regex_t preg;
+		const char *this_sym;
+		size_t n;
+		int flags = REG_EXTENDED | REG_NOSUB | (g_match > 1 ? REG_ICASE : 0);
+
+		array_for_each(find_sym_arr, n, this_sym) {
+			/* see scanelf_match_symname for logic info */
+			switch (this_sym[0]) {
+			case '%':
+				while (*(this_sym++))
+					if (*this_sym == '%') {
+						++this_sym;
+						break;
+					}
+				break;
+			case '+':
+			case '-':
+				++this_sym;
+				break;
+			}
+			if (*this_sym == '*')
+				++this_sym;
+
+			ret = regcomp(&preg, this_sym, flags);
+			if (ret) {
+				char err[256];
+				regerror(ret, &preg, err, sizeof(err));
+				err("regcomp of %s failed: %s", this_sym, err);
+			}
+			xarraypush(find_sym_regex_arr, &preg, sizeof(preg));
+		}
+	}
 	/* flatten arrays for display */
 	if (array_cnt(find_sym_arr))
 		find_sym = array_flatten_str(find_sym_arr);
@@ -2322,6 +2334,13 @@
 	free(find_sym);
 	free(find_lib);
 	free(find_section);
+	{
+		size_t n;
+		regex_t *preg;
+		array_for_each(find_sym_regex_arr, n, preg)
+			regfree(preg);
+		xarrayfree(find_sym_regex_arr);
+	}
 
 	if (ldcache != 0)
 		munmap(ldcache, ldcache_size);





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2012-11-04  8:25 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-04  8:25 UTC (permalink / raw
  To: gentoo-commits

vapier      12/11/04 08:25:41

  Modified:             scanelf.c
  Log:
  skip freeing of memory at exit since the kernel takes care of that for us

Revision  Changes    Path
1.250                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.250&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.250&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.249&r2=1.250

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.249
retrieving revision 1.250
diff -u -r1.249 -r1.250
--- scanelf.c	4 Nov 2012 08:23:12 -0000	1.249
+++ scanelf.c	4 Nov 2012 08:25:41 -0000	1.250
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.249 2012/11/04 08:23:12 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.250 2012/11/04 08:25:41 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.249 2012/11/04 08:23:12 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.250 2012/11/04 08:25:41 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -2326,6 +2326,7 @@
 		ret = scanelf_dir(search_path);
 	}
 
+#ifdef __PAX_UTILS_CLEANUP
 	/* clean up */
 	xarrayfree(ldpaths);
 	xarrayfree(find_sym_arr);
@@ -2344,6 +2345,8 @@
 
 	if (ldcache != 0)
 		munmap(ldcache, ldcache_size);
+#endif
+
 	return ret;
 }
 





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2012-11-10  9:43 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-10  9:43 UTC (permalink / raw
  To: gentoo-commits

vapier      12/11/10 09:43:00

  Modified:             scanelf.c
  Log:
  scanelf: use PT_INTERP if .interp could not be found

Revision  Changes    Path
1.251                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.251&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.251&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.250&r2=1.251

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.250
retrieving revision 1.251
diff -u -r1.250 -r1.251
--- scanelf.c	4 Nov 2012 08:25:41 -0000	1.250
+++ scanelf.c	10 Nov 2012 09:43:00 -0000	1.251
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.250 2012/11/04 08:25:41 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.251 2012/11/10 09:43:00 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.250 2012/11/04 08:25:41 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.251 2012/11/10 09:43:00 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -1022,7 +1022,24 @@
 		}
 		SHOW_INTERP(32)
 		SHOW_INTERP(64)
+	} else {
+		/* Walk all the program headers to find the PT_INTERP */
+#define SHOW_PT_INTERP(B) \
+		if (elf->elf_class == ELFCLASS ## B) { \
+		unsigned long i; \
+		Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
+		Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \
+		for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
+			if (EGET(phdr[i].p_type) != PT_INTERP) \
+				continue; \
+			*found_interp = 1; \
+			return (be_wewy_wewy_quiet ? NULL : elf->data + EGET(phdr[i].p_offset)); \
+		} \
+		}
+		SHOW_PT_INTERP(32)
+		SHOW_PT_INTERP(64)
 	}
+
 	return NULL;
 }
 static char *scanelf_file_bind(elfobj *elf, char *found_bind)





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2012-11-30 23:25 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-30 23:25 UTC (permalink / raw
  To: gentoo-commits

vapier      12/11/30 23:25:07

  Modified:             scanelf.c
  Log:
  update ldconfig flags

Revision  Changes    Path
1.253                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.253&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.253&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.252&r2=1.253

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.252
retrieving revision 1.253
diff -u -r1.252 -r1.253
--- scanelf.c	18 Nov 2012 07:39:45 -0000	1.252
+++ scanelf.c	30 Nov 2012 23:25:07 -0000	1.253
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.252 2012/11/18 07:39:45 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.253 2012/11/30 23:25:07 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.252 2012/11/18 07:39:45 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.253 2012/11/30 23:25:07 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -765,6 +765,7 @@
 		xstrcat(ret, "  -  ", ret_len);
 }
 
+/* Defines can be seen in glibc's sysdeps/generic/ldconfig.h */
 #define LDSO_CACHE_MAGIC "ld.so-"
 #define LDSO_CACHE_MAGIC_LEN (sizeof LDSO_CACHE_MAGIC -1)
 #define LDSO_CACHE_VER "1.7.0"
@@ -783,6 +784,9 @@
 #define FLAG_POWERPC_LIB64  0x0500
 #define FLAG_MIPS64_LIBN32  0x0600
 #define FLAG_MIPS64_LIBN64  0x0700
+#define FLAG_X8664_LIBX32   0x0800
+#define FLAG_ARM_LIBHF      0x0900
+#define FLAG_AARCH64_LIB64  0x0a00
 
 #if defined(__GLIBC__) || defined(__UCLIBC__)
 





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2013-04-02 21:15 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-02 21:15 UTC (permalink / raw
  To: gentoo-commits

vapier      13/04/02 21:15:50

  Modified:             scanelf.c
  Log:
  scanelf: put the opendir() warning at the same verbose level as open() warning

Revision  Changes    Path
1.255                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.255&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.255&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.254&r2=1.255

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.254
retrieving revision 1.255
diff -u -r1.254 -r1.255
--- scanelf.c	2 Apr 2013 21:13:05 -0000	1.254
+++ scanelf.c	2 Apr 2013 21:15:50 -0000	1.255
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.254 2013/04/02 21:13:05 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.255 2013/04/02 21:15:50 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.254 2013/04/02 21:13:05 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.255 2013/04/02 21:15:50 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -1692,7 +1692,8 @@
 	if (dir == NULL) {
 		if (subdir_fd != -1)
 			close(subdir_fd);
-		warnfp("could not opendir(%s)", path);
+		else if (be_verbose > 2)
+			printf("%s: skipping dir: %s\n", path, strerror(errno));
 		return 1;
 	}
 	if (be_verbose > 1) printf("%s: scanning dir\n", path);





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2013-04-08  6:38 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-08  6:38 UTC (permalink / raw
  To: gentoo-commits

vapier      13/04/08 06:38:42

  Modified:             scanelf.c
  Log:
  scanelf: auto-align help output

Revision  Changes    Path
1.256                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.256&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.256&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.255&r2=1.256

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.255
retrieving revision 1.256
diff -u -r1.255 -r1.256
--- scanelf.c	2 Apr 2013 21:15:50 -0000	1.255
+++ scanelf.c	8 Apr 2013 06:38:42 -0000	1.256
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.255 2013/04/02 21:15:50 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.256 2013/04/08 06:38:42 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.255 2013/04/02 21:15:50 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.256 2013/04/08 06:38:42 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -2030,10 +2030,23 @@
 /* display usage and exit */
 static void usage(int status)
 {
-	unsigned long i;
+	const char a_arg[] = "<arg>";
+	size_t a_arg_len = strlen(a_arg) + 2;
+	size_t i;
+	int optlen;
 	printf("* Scan ELF binaries for stuff\n\n"
 	       "Usage: %s [options] <dir1/file1> [dir2 dirN file2 fileN ...]\n\n", argv0);
 	printf("Options: -[%s]\n", PARSE_FLAGS);
+
+	/* prescan the --long opt length to auto-align */
+	optlen = 0;
+	for (i = 0; long_opts[i].name; ++i) {
+		int l = strlen(long_opts[i].name);
+		if (long_opts[i].has_arg == a_argument)
+			l += a_arg_len;
+		optlen = max(l, optlen);
+	}
+
 	for (i = 0; long_opts[i].name; ++i) {
 		/* first output the short flag if it has one */
 		if (long_opts[i].val > '~')
@@ -2043,9 +2056,10 @@
 
 		/* then the long flag */
 		if (long_opts[i].has_arg == no_argument)
-			printf("--%-14s", long_opts[i].name);
+			printf("--%-*s", optlen, long_opts[i].name);
 		else
-			printf("--%-7s <arg> ", long_opts[i].name);
+			printf("--%s %s %*s", long_opts[i].name, a_arg,
+				(int)(optlen - strlen(long_opts[i].name) - a_arg_len), "");
 
 		/* finally the help text */
 		printf("* %s\n", opts_help[i]);





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2013-04-10 22:27 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-10 22:27 UTC (permalink / raw
  To: gentoo-commits

vapier      13/04/10 22:27:21

  Modified:             scanelf.c
  Log:
  scanelf: fix more warnings from gcc-4.8

Revision  Changes    Path
1.257                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.257&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.257&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.256&r2=1.257

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.256
retrieving revision 1.257
diff -u -r1.256 -r1.257
--- scanelf.c	8 Apr 2013 06:38:42 -0000	1.256
+++ scanelf.c	10 Apr 2013 22:27:20 -0000	1.257
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.256 2013/04/08 06:38:42 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.257 2013/04/10 22:27:20 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.256 2013/04/08 06:38:42 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.257 2013/04/10 22:27:20 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -582,7 +582,7 @@
 					elf->filename, \
 					(unsigned long)r_offset); \
 				fflush(stdout); \
-				if (system(sysbuf)) /* don't care */; \
+				if (system(sysbuf)) {/* don't care */} \
 				fflush(stdout); \
 				free(sysbuf); \
 			} \
@@ -903,7 +903,7 @@
 }
 #endif
 
-static char *lookup_config_lib(elfobj *elf, char *fname)
+static char *lookup_config_lib(const char *fname)
 {
 	static char buf[__PAX_UTILS_PATH_MAX] = "";
 	const char *ldpath;
@@ -965,7 +965,7 @@
 						if (!be_wewy_wewy_quiet) { \
 							if (*found_needed) xchrcat(ret, ',', ret_len); \
 							if (use_ldpath) { \
-								if ((p = lookup_config_lib(elf, needed)) != NULL) \
+								if ((p = lookup_config_lib(needed)) != NULL) \
 									needed = p; \
 							} else if (use_ldcache) { \
 								if ((p = lookup_cache_lib(elf, needed)) != NULL) \
@@ -1041,7 +1041,7 @@
 
 	return NULL;
 }
-static char *scanelf_file_bind(elfobj *elf, char *found_bind)
+static const char *scanelf_file_bind(elfobj *elf, char *found_bind)
 {
 	unsigned long i;
 	struct stat s;
@@ -1084,7 +1084,7 @@
 		return NULL;
 	} else {
 		*found_bind = 1;
-		return (char *)(dynamic ? "LAZY" : "STATIC");
+		return dynamic ? "LAZY" : "STATIC";
 	}
 }
 static char *scanelf_file_soname(elfobj *elf, char *found_soname)
@@ -1829,7 +1829,7 @@
 
 	if (curr_fd != -1) {
 		if (fchdir(curr_fd))
-			/* don't care */;
+			{/* don't care */}
 		close(curr_fd);
 	}
 





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2013-04-16 16:22 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-16 16:22 UTC (permalink / raw
  To: gentoo-commits

vapier      13/04/16 16:22:32

  Modified:             scanelf.c
  Log:
  scanelf: use bool rather than char to avoid bogus gcc warning (filed upstream already)

Revision  Changes    Path
1.258                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.258&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.258&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.257&r2=1.258

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.257
retrieving revision 1.258
diff -u -r1.257 -r1.258
--- scanelf.c	10 Apr 2013 22:27:20 -0000	1.257
+++ scanelf.c	16 Apr 2013 16:22:31 -0000	1.258
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.257 2013/04/10 22:27:20 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.258 2013/04/16 16:22:31 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.257 2013/04/10 22:27:20 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.258 2013/04/16 16:22:31 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -1045,7 +1045,7 @@
 {
 	unsigned long i;
 	struct stat s;
-	char dynamic = 0;
+	bool dynamic = false;
 
 	if (!show_bind) return NULL;
 	if (!elf->phdr) return NULL;
@@ -1058,7 +1058,7 @@
 		Elf ## B ## _Off offset; \
 		for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
 			if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \
-			dynamic = 1; \
+			dynamic = true; \
 			offset = EGET(phdr[i].p_offset); \
 			if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \
 			dyn = DYN ## B (elf->vdata + offset); \





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2013-08-14 21:09 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2013-08-14 21:09 UTC (permalink / raw
  To: gentoo-commits

vapier      13/08/14 21:09:57

  Modified:             scanelf.c
  Log:
  scanelf: flag object files that have a +x stack (even if it is -w) since its almost assured the final ELF will add +w automatically
  
  this makes a difference too -- see bug 445962 where dvdauthor produced a mpeg2desc.o that had a +x w/gcc-4.8 and a nested function, but the output only flagged the final mpeg2desc binary as that included +w stack markings

Revision  Changes    Path
1.259                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.259&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.259&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.258&r2=1.259

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.258
retrieving revision 1.259
diff -u -r1.258 -r1.259
--- scanelf.c	16 Apr 2013 16:22:31 -0000	1.258
+++ scanelf.c	14 Aug 2013 21:09:57 -0000	1.259
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.258 2013/04/16 16:22:31 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.259 2013/08/14 21:09:57 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.258 2013/04/16 16:22:31 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.259 2013/08/14 21:09:57 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -379,7 +379,11 @@
 		char *str; \
 		if ((void*)strtbl > elf->data_end) \
 			goto skip_this_shdr##B; \
-		check_flags = SHF_WRITE|SHF_EXECINSTR; \
+		/* let's flag -w/+x object files since the final ELF will most likely
+		 * need write access to the stack (who doesn't !?).  so the combined
+		 * output will bring in +w automatically and that's bad.
+		 */
+		check_flags = /*SHF_WRITE|*/SHF_EXECINSTR; \
 		for (i = 0; i < EGET(ehdr->e_shnum); ++i) { \
 			if (EGET(shdr[i].sh_type) != SHT_PROGBITS) continue; \
 			offset = EGET(strtbl->sh_offset) + EGET(shdr[i].sh_name); \





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2014-01-11  0:28 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2014-01-11  0:28 UTC (permalink / raw
  To: gentoo-commits

vapier      14/01/11 00:28:49

  Modified:             scanelf.c
  Log:
  scanelf: fix comment in middle of define

Revision  Changes    Path
1.260                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.260&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.260&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.259&r2=1.260

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.259
retrieving revision 1.260
diff -u -r1.259 -r1.260
--- scanelf.c	14 Aug 2013 21:09:57 -0000	1.259
+++ scanelf.c	11 Jan 2014 00:28:49 -0000	1.260
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.259 2013/08/14 21:09:57 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.260 2014/01/11 00:28:49 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.259 2013/08/14 21:09:57 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.260 2014/01/11 00:28:49 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -379,10 +379,10 @@
 		char *str; \
 		if ((void*)strtbl > elf->data_end) \
 			goto skip_this_shdr##B; \
-		/* let's flag -w/+x object files since the final ELF will most likely
-		 * need write access to the stack (who doesn't !?).  so the combined
-		 * output will bring in +w automatically and that's bad.
-		 */
+		/* let's flag -w/+x object files since the final ELF will most likely \
+		 * need write access to the stack (who doesn't !?).  so the combined \
+		 * output will bring in +w automatically and that's bad. \
+		 */ \
 		check_flags = /*SHF_WRITE|*/SHF_EXECINSTR; \
 		for (i = 0; i < EGET(ehdr->e_shnum); ++i) { \
 			if (EGET(shdr[i].sh_type) != SHT_PROGBITS) continue; \





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2014-03-20  8:06 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2014-03-20  8:06 UTC (permalink / raw
  To: gentoo-commits

vapier      14/03/20 08:06:01

  Modified:             scanelf.c
  Log:
  scanelf: convert -E option to use array_t
  
  this avoids silently (and wrongly) truncating the options given to -E.  it also makes the code a lot easier to handle.
  
  #504340 by David Binderman

Revision  Changes    Path
1.262                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.262&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.262&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.261&r2=1.262

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.261
retrieving revision 1.262
diff -u -r1.261 -r1.262
--- scanelf.c	20 Mar 2014 07:59:27 -0000	1.261
+++ scanelf.c	20 Mar 2014 08:06:01 -0000	1.262
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.261 2014/03/20 07:59:27 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.262 2014/03/20 08:06:01 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.261 2014/03/20 07:59:27 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.262 2014/03/20 08:06:01 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -18,7 +18,7 @@
 static int file_matches_list(const char *filename, char **matchlist);
 
 /* variables to control behavior */
-static char *match_etypes = NULL;
+static array_t _match_etypes = array_init_decl, *match_etypes = &_match_etypes;
 static array_t _ldpaths = array_init_decl, *ldpaths = &_ldpaths;
 static char scan_ldpath = 0;
 static char scan_envpath = 0;
@@ -1550,6 +1550,8 @@
 static int scanelf_elf(const char *filename, int fd, size_t len)
 {
 	int ret = 1;
+	size_t n;
+	const char *match_etype;
 	elfobj *elf;
 
 	/* verify this is real ELF */
@@ -1568,20 +1570,12 @@
 			break;
 		default: break;
 	}
-	if (match_etypes) {
-		char sbuf[126];
-		strncpy(sbuf, match_etypes, sizeof(sbuf));
-		if (strchr(match_etypes, ',') != NULL) {
-			char *p;
-			while ((p = strrchr(sbuf, ',')) != NULL) {
-				*p = 0;
-				if (etype_lookup(p+1) == get_etype(elf))
-					goto label_ret;
-			}
-		}
-		if (etype_lookup(sbuf) != get_etype(elf))
-			goto label_done;
-	}
+
+	array_for_each(match_etypes, n, match_etype)
+		if (etype_lookup(match_etype) == get_etype(elf))
+			goto label_ret;
+	if (array_cnt(match_etypes))
+		goto label_done;
 
 label_ret:
 	ret = scanelf_elfobj(elf);
@@ -2080,6 +2074,16 @@
 		flags &= ~PF_NO##flag; \
 		flags |= PF_##flag; \
 	}
+static void parse_delimited(array_t *arr, char *arg, const char *delim)
+{
+	char *ele = strtok(arg, delim);
+	if (!ele)	/* edge case: -s '' */
+		xarraypush_str(arr, "");
+	while (ele) {
+		xarraypush_str(arr, ele);
+		ele = strtok(NULL, delim);
+	}
+}
 static int parseargs(int argc, char *argv[])
 {
 	int i;
@@ -2103,7 +2107,8 @@
 			from_file = optarg;
 			break;
 		case 'E':
-			match_etypes = optarg;
+			/* historically, this was comma delimited */
+			parse_delimited(match_etypes, optarg, ",");
 			break;
 		case 'M':
 			match_bits = atoi(optarg);
@@ -2126,17 +2131,10 @@
 		case 'k':
 			xarraypush_str(find_section_arr, optarg);
 			break;
-		case 's': {
+		case 's':
 			/* historically, this was comma delimited */
-			char *this_sym = strtok(optarg, ",");
-			if (!this_sym)	/* edge case: -s '' */
-				xarraypush_str(find_sym_arr, "");
-			while (this_sym) {
-				xarraypush_str(find_sym_arr, this_sym);
-				this_sym = strtok(NULL, ",");
-			}
+			parse_delimited(find_sym_arr, optarg, ",");
 			break;
-		}
 		case 'N':
 			xarraypush_str(find_lib_arr, optarg);
 			break;





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2014-03-20  8:08 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2014-03-20  8:08 UTC (permalink / raw
  To: gentoo-commits

vapier      14/03/20 08:08:37

  Modified:             scanelf.c
  Log:
  tweak style -- no functional changes

Revision  Changes    Path
1.263                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.263&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.263&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.262&r2=1.263

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.262
retrieving revision 1.263
diff -u -r1.262 -r1.263
--- scanelf.c	20 Mar 2014 08:06:01 -0000	1.262
+++ scanelf.c	20 Mar 2014 08:08:37 -0000	1.263
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.262 2014/03/20 08:06:01 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.263 2014/03/20 08:08:37 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.262 2014/03/20 08:06:01 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.263 2014/03/20 08:08:37 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -1554,33 +1554,35 @@
 	const char *match_etype;
 	elfobj *elf;
 
-	/* verify this is real ELF */
+	/* Verify this is a real ELF */
 	if ((elf = _readelf_fd(filename, fd, len, !fix_elf)) == NULL) {
 		if (be_verbose > 2) printf("%s: not an ELF\n", filename);
 		return 2;
 	}
+
+	/* Possibly filter based on ELF bitness */
 	switch (match_bits) {
-		case 32:
-			if (elf->elf_class != ELFCLASS32)
-				goto label_done;
-			break;
-		case 64:
-			if (elf->elf_class != ELFCLASS64)
-				goto label_done;
-			break;
-		default: break;
+	case 32:
+		if (elf->elf_class != ELFCLASS32)
+			goto done;
+		break;
+	case 64:
+		if (elf->elf_class != ELFCLASS64)
+			goto done;
+		break;
 	}
 
+	/* Possibly filter based on the ELF's e_type field */
 	array_for_each(match_etypes, n, match_etype)
 		if (etype_lookup(match_etype) == get_etype(elf))
-			goto label_ret;
+			goto scanit;
 	if (array_cnt(match_etypes))
-		goto label_done;
+		goto done;
 
-label_ret:
+ scanit:
 	ret = scanelf_elfobj(elf);
 
-label_done:
+ done:
 	unreadelf(elf);
 	return ret;
 }





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2014-03-21  5:27 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2014-03-21  5:27 UTC (permalink / raw
  To: gentoo-commits

vapier      14/03/21 05:27:21

  Modified:             scanelf.c
  Log:
  rewrite which() so that it works and does not break $PATH
  
  we were walking the $PATH in reverse which it should have been forwards.  we were also modifying the pointer we got back from getenv() which meant any time we ran external code, $PATH would be truncated.  finally, we never actually checked the first element -- we would bail before we got a chance.

Revision  Changes    Path
1.264                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.264&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.264&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.263&r2=1.264

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.263
retrieving revision 1.264
diff -u -r1.263 -r1.264
--- scanelf.c	20 Mar 2014 08:08:37 -0000	1.263
+++ scanelf.c	21 Mar 2014 05:27:21 -0000	1.264
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.263 2014/03/20 08:08:37 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.264 2014/03/21 05:27:21 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.263 2014/03/20 08:08:37 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.264 2014/03/21 05:27:21 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -70,26 +70,66 @@
 static size_t ldcache_size = 0;
 static unsigned long setpax = 0UL;
 
-static int has_objdump = 0;
+static const char *objdump;
 
 /* find the path to a file by name */
-static int bin_in_path(const char *fname)
+static const char *which(const char *fname, const char *envvar)
 {
-	char fullpath[__PAX_UTILS_PATH_MAX];
-	char *path, *p;
+	size_t path_len, fname_len;
+	const char *env_path;
+	char *path, *p, *ep;
+
+	p = getenv(envvar);
+	if (p)
+		return p;
 
-	path = getenv("PATH");
-	if (!path)
-		return 0;
+	env_path = getenv("PATH");
+	if (!env_path)
+		return NULL;
 
-	while ((p = strrchr(path, ':')) != NULL) {
-		snprintf(fullpath, sizeof(fullpath), "%s/%s", p + 1, fname);
-		*p = 0;
-		if (access(fullpath, R_OK) != -1)
-			return 1;
+	/* Create a copy of the $PATH that we can safely modify.
+	 * Make it a little bigger so we can append "/fname".
+	 * We do this twice -- once for a perm copy, and once for
+	 * room at the end of the last element. */
+	path_len = strlen(env_path);
+	fname_len = strlen(fname);
+	path = xmalloc(path_len + (fname_len * 2) + 2 + 2);
+	memcpy(path, env_path, path_len + 1);
+
+	p = path + path_len + 1 + fname_len + 1;
+	*p = '/';
+	memcpy(p + 1, fname, fname_len + 1);
+
+	/* Repoint fname to the copy in the env string as it has
+	 * the leading slash which we can include in a single memcpy.
+	 * Increase the fname len to include the '/' and '\0'. */
+	fname = p;
+	fname_len += 2;
+
+	p = path;
+	while (p) {
+		ep = strchr(p, ':');
+		/* Append the /foo path to the current element. */
+		if (ep)
+			memcpy(ep, fname, fname_len);
+		else
+			memcpy(path + path_len, fname, fname_len);
+
+		if (access(p, R_OK) != -1)
+			return p;
+
+		p = ep;
+		if (ep) {
+			/* If not the last element, restore the chunk we clobbered. */
+			size_t offset = ep - path;
+			size_t restore = min(path_len - offset, fname_len);
+			memcpy(ep, env_path + offset, restore);
+			++p;
+		}
 	}
 
-	return 0;
+	free(path);
+	return NULL;
 }
 
 static FILE *fopenat_r(int dir_fd, const char *path)
@@ -570,17 +610,18 @@
 			} else \
 				printf("(optimized out)"); \
 			printf(" [0x%lX]\n", (unsigned long)offset_tmp); \
-			if (be_verbose && has_objdump) { \
+			if (be_verbose && objdump) { \
 				Elf ## B ## _Addr end_addr = offset_tmp + EGET(func->st_size); \
 				char *sysbuf; \
 				size_t syslen; \
-				const char sysfmt[] = "objdump -r -R -d -w -l --start-address=0x%lX --stop-address=0x%lX %s | grep --color -i -C 3 '.*[[:space:]]%lX:[[:space:]]*R_.*'\n"; \
-				syslen = sizeof(sysfmt) + strlen(elf->filename) + 3 * sizeof(unsigned long) + 1; \
+				const char sysfmt[] = "%s -r -R -d -w -l --start-address=0x%lX --stop-address=0x%lX %s | grep --color -i -C 3 '.*[[:space:]]%lX:[[:space:]]*R_.*'\n"; \
+				syslen = sizeof(sysfmt) + strlen(objdump) + strlen(elf->filename) + 3 * sizeof(unsigned long) + 1; \
 				sysbuf = xmalloc(syslen); \
 				if (end_addr < r_offset) \
 					/* not uncommon when things are optimized out */ \
 					end_addr = r_offset + 0x100; \
 				snprintf(sysbuf, syslen, sysfmt, \
+					objdump, \
 					(unsigned long)offset_tmp, \
 					(unsigned long)end_addr, \
 					elf->filename, \
@@ -2230,7 +2271,7 @@
 		}
 	}
 	if (show_textrels && be_verbose)
-		has_objdump = bin_in_path("objdump");
+		objdump = which("objdump", "OBJDUMP");
 	/* precompile all the regexes */
 	if (g_match) {
 		regex_t preg;





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2014-03-21  5:33 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2014-03-21  5:33 UTC (permalink / raw
  To: gentoo-commits

vapier      14/03/21 05:33:33

  Modified:             scanelf.c
  Log:
  note that which() does not handle PATH="/foo::/bar" correctly

Revision  Changes    Path
1.265                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.265&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.265&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.264&r2=1.265

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.264
retrieving revision 1.265
diff -u -r1.264 -r1.265
--- scanelf.c	21 Mar 2014 05:27:21 -0000	1.264
+++ scanelf.c	21 Mar 2014 05:33:33 -0000	1.265
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.264 2014/03/21 05:27:21 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.265 2014/03/21 05:33:33 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.264 2014/03/21 05:27:21 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.265 2014/03/21 05:33:33 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -72,7 +72,8 @@
 
 static const char *objdump;
 
-/* find the path to a file by name */
+/* Find the path to a file by name.  Note: we do not currently handle the
+ * empty path element correctly (should behave by searching $PWD). */
 static const char *which(const char *fname, const char *envvar)
 {
 	size_t path_len, fname_len;





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2014-10-19  7:31 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2014-10-19  7:31 UTC (permalink / raw
  To: gentoo-commits

vapier      14/10/19 07:31:20

  Modified:             scanelf.c
  Log:
  scanelf: do not use debug syms with runtime strings or vice versa

Revision  Changes    Path
1.267                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.267&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.267&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.266&r2=1.267

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.266
retrieving revision 1.267
diff -u -r1.266 -r1.267
--- scanelf.c	18 Jun 2014 03:16:52 -0000	1.266
+++ scanelf.c	19 Oct 2014 07:31:20 -0000	1.267
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.266 2014/06/18 03:16:52 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.267 2014/10/19 07:31:20 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.266 2014/06/18 03:16:52 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.267 2014/10/19 07:31:20 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -178,6 +178,9 @@
 	 * skip them.  This let's us work sanely with splitdebug ELFs (rather
 	 * than spewing a lot of "corrupt ELF" messages later on).  In malformed
 	 * ELFs, the section might be wrongly set to NOBITS, but screw em.
+	 *
+	 * We need to make sure the debug/runtime sym/str sets are used together
+	 * as they are generated in sync.  Trying to mix them won't work.
 	 */
 #define GET_SYMTABS(B) \
 	if (elf->elf_class == ELFCLASS ## B) { \
@@ -190,19 +193,28 @@
 		symtab = NULL; \
 	if (dynsym && EGET(edynsym->sh_type) == SHT_NOBITS) \
 		dynsym = NULL; \
-	if (symtab && dynsym) \
-		*sym = (EGET(esymtab->sh_size) > EGET(edynsym->sh_size)) ? symtab : dynsym; \
-	else \
-		*sym = symtab ? symtab : dynsym; \
-	\
 	if (strtab && EGET(estrtab->sh_type) == SHT_NOBITS) \
 		strtab = NULL; \
 	if (dynstr && EGET(edynstr->sh_type) == SHT_NOBITS) \
 		dynstr = NULL; \
-	if (strtab && dynstr) \
-		*str = (EGET(estrtab->sh_size) > EGET(edynstr->sh_size)) ? strtab : dynstr; \
-	else \
-		*str = strtab ? strtab : dynstr; \
+	\
+	/* Use the set with more symbols if both exist. */ \
+	if (symtab && dynsym && strtab && dynstr) { \
+		if (EGET(esymtab->sh_size) > EGET(edynsym->sh_size)) \
+			goto debug##B; \
+		else \
+			goto runtime##B; \
+	} else if (symtab && strtab) { \
+ debug##B: \
+		*sym = symtab; \
+		*str = strtab; \
+		return; \
+	} else if (dynsym && dynstr) { \
+ runtime##B: \
+		*sym = dynsym; \
+		*str = dynstr; \
+		return; \
+	} \
 	}
 	GET_SYMTABS(32)
 	GET_SYMTABS(64)





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2014-11-05  2:02 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2014-11-05  2:02 UTC (permalink / raw
  To: gentoo-commits

vapier      14/11/05 02:02:03

  Modified:             scanelf.c
  Log:
  scanelf: make sure to clear the symtab inputs when the section does not match #527490 by Juergen Rose

Revision  Changes    Path
1.268                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.268&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.268&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.267&r2=1.268

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.267
retrieving revision 1.268
diff -u -r1.267 -r1.268
--- scanelf.c	19 Oct 2014 07:31:20 -0000	1.267
+++ scanelf.c	5 Nov 2014 02:02:03 -0000	1.268
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.267 2014/10/19 07:31:20 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.268 2014/11/05 02:02:03 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.267 2014/10/19 07:31:20 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.268 2014/11/05 02:02:03 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -214,6 +214,8 @@
 		*sym = dynsym; \
 		*str = dynstr; \
 		return; \
+	} else { \
+		*sym = *str = NULL; \
 	} \
 	}
 	GET_SYMTABS(32)





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2014-11-20  1:25 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2014-11-20  1:25 UTC (permalink / raw
  To: gentoo-commits

vapier      14/11/20 01:25:56

  Modified:             scanelf.c
  Log:
  scanelf: add a note in the rpath warning when we fix the ELF automatically #334819 by Dennis Schridde

Revision  Changes    Path
1.269                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.269&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.269&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.268&r2=1.269

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.268
retrieving revision 1.269
diff -u -r1.268 -r1.269
--- scanelf.c	5 Nov 2014 02:02:03 -0000	1.268
+++ scanelf.c	20 Nov 2014 01:25:56 -0000	1.269
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.268 2014/11/05 02:02:03 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.269 2014/11/20 01:25:56 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.268 2014/11/05 02:02:03 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.269 2014/11/20 01:25:56 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -679,6 +679,8 @@
 			warnf("Maybe? sec problem with %s='%s' in %s", dt_type, item, elf->filename);
 			break;
 	}
+	if (fix_elf)
+		warnf("Note: RPATH has been automatically fixed, but this should be fixed in the package itself");
 }
 static void scanelf_file_rpath(elfobj *elf, char *found_rpath, char **ret, size_t *ret_len)
 {





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2015-02-21 19:30 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2015-02-21 19:30 UTC (permalink / raw
  To: gentoo-commits

vapier      15/02/21 19:30:59

  Modified:             scanelf.c
  Log:
  scanelf: fix logic error in shdr string overflow
  
  Reported-by: Jakub Wilk <jwilk@debian.org>
  URL: https://bugs.debian.org/775270

Revision  Changes    Path
1.270                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.270&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.270&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.269&r2=1.270

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.269
retrieving revision 1.270
diff -u -r1.269 -r1.270
--- scanelf.c	20 Nov 2014 01:25:56 -0000	1.269
+++ scanelf.c	21 Feb 2015 19:30:59 -0000	1.270
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.269 2014/11/20 01:25:56 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.270 2015/02/21 19:30:59 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.269 2014/11/20 01:25:56 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.270 2015/02/21 19:30:59 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -443,7 +443,7 @@
 			if (EGET(shdr[i].sh_type) != SHT_PROGBITS) continue; \
 			offset = EGET(strtbl->sh_offset) + EGET(shdr[i].sh_name); \
 			str = elf->data + offset; \
-			if (str > elf->data + offset + sizeof(NOTE_GNU_STACK)) continue; \
+			if (str + sizeof(NOTE_GNU_STACK) > elf->data + elf->len) continue; \
 			if (!strcmp(str, NOTE_GNU_STACK)) { \
 				if (multi_stack++) warnf("%s: multiple .note.GNU-stack's !?", elf->filename); \
 				flags = EGET(shdr[i].sh_flags); \





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2015-02-22  0:10 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2015-02-22  0:10 UTC (permalink / raw
  To: gentoo-commits

vapier      15/02/22 00:10:27

  Modified:             scanelf.c
  Log:
  scanelf: improve shdr string overflow check more
  
  Rather than operate on the result of the pointers (which might have
  overflowed due to the offset being huge), check the offset directly
  against the size of the file like we do elsewhere in scanelf.

Revision  Changes    Path
1.271                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.271&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.271&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.270&r2=1.271

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.270
retrieving revision 1.271
diff -u -r1.270 -r1.271
--- scanelf.c	21 Feb 2015 19:30:59 -0000	1.270
+++ scanelf.c	22 Feb 2015 00:10:27 -0000	1.271
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.270 2015/02/21 19:30:59 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.271 2015/02/22 00:10:27 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.270 2015/02/21 19:30:59 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.271 2015/02/22 00:10:27 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -431,7 +431,6 @@
 		/* no program headers which means this is prob an object file */ \
 		Elf ## B ## _Shdr *shdr = SHDR ## B (elf->shdr); \
 		Elf ## B ## _Shdr *strtbl = shdr + EGET(ehdr->e_shstrndx); \
-		char *str; \
 		if ((void*)strtbl > elf->data_end) \
 			goto skip_this_shdr##B; \
 		/* let's flag -w/+x object files since the final ELF will most likely \
@@ -442,9 +441,9 @@
 		for (i = 0; i < EGET(ehdr->e_shnum); ++i) { \
 			if (EGET(shdr[i].sh_type) != SHT_PROGBITS) continue; \
 			offset = EGET(strtbl->sh_offset) + EGET(shdr[i].sh_name); \
-			str = elf->data + offset; \
-			if (str + sizeof(NOTE_GNU_STACK) > elf->data + elf->len) continue; \
-			if (!strcmp(str, NOTE_GNU_STACK)) { \
+			if (offset >= elf->len - sizeof(NOTE_GNU_STACK)) \
+				continue; \
+			if (!strcmp(elf->data + offset, NOTE_GNU_STACK)) { \
 				if (multi_stack++) warnf("%s: multiple .note.GNU-stack's !?", elf->filename); \
 				flags = EGET(shdr[i].sh_flags); \
 				if (be_quiet && ((flags & check_flags) != check_flags)) \





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2015-02-22  1:38 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2015-02-22  1:38 UTC (permalink / raw
  To: gentoo-commits

vapier      15/02/22 01:38:28

  Modified:             scanelf.c
  Log:
  scanelf: add a few more elf->phdr checks

Revision  Changes    Path
1.273                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.273&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.273&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.272&r2=1.273

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.272
retrieving revision 1.273
diff -u -r1.272 -r1.273
--- scanelf.c	22 Feb 2015 00:54:34 -0000	1.272
+++ scanelf.c	22 Feb 2015 01:38:28 -0000	1.273
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.272 2015/02/22 00:54:34 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.273 2015/02/22 01:38:28 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.272 2015/02/22 00:54:34 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.273 2015/02/22 01:38:28 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -229,6 +229,8 @@
 	 * reconstruct the section header info out of the dynamic
 	 * tags so we can see what symbols this guy uses at runtime.
 	 */
+	if (!elf->phdr)
+		return;
 #define GET_SYMTABS_DT(B) \
 	if (elf->elf_class == ELFCLASS ## B) { \
 	size_t i; \
@@ -1082,7 +1084,7 @@
 		}
 		SHOW_INTERP(32)
 		SHOW_INTERP(64)
-	} else {
+	} else if (elf->phdr) {
 		/* Walk all the program headers to find the PT_INTERP */
 #define SHOW_PT_INTERP(B) \
 		if (elf->elf_class == ELFCLASS ## B) { \





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2015-02-22  2:27 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2015-02-22  2:27 UTC (permalink / raw
  To: gentoo-commits

vapier      15/02/22 02:27:39

  Modified:             scanelf.c
  Log:
  scanelf: rework interp lookup
  
  Prefer PT_INTERP over the section headers since that gets used at runtime.
  Add verification to the pointer we do find.

Revision  Changes    Path
1.274                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.274&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.274&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.273&r2=1.274

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.273
retrieving revision 1.274
diff -u -r1.273 -r1.274
--- scanelf.c	22 Feb 2015 01:38:28 -0000	1.273
+++ scanelf.c	22 Feb 2015 02:27:39 -0000	1.274
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.273 2015/02/22 01:38:28 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.274 2015/02/22 02:27:39 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.273 2015/02/22 01:38:28 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.274 2015/02/22 02:27:39 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -1069,37 +1069,51 @@
 }
 static char *scanelf_file_interp(elfobj *elf, char *found_interp)
 {
-	void *strtbl_void;
+	uint64_t offset = 0;
 
 	if (!show_interp) return NULL;
 
-	strtbl_void = elf_findsecbyname(elf, ".interp");
-
-	if (strtbl_void) {
-#define SHOW_INTERP(B) \
-		if (elf->elf_class == ELFCLASS ## B) { \
-			Elf ## B ## _Shdr *strtbl = SHDR ## B (strtbl_void); \
-			*found_interp = 1; \
-			return (be_wewy_wewy_quiet ? NULL : elf->data + EGET(strtbl->sh_offset)); \
-		}
-		SHOW_INTERP(32)
-		SHOW_INTERP(64)
-	} else if (elf->phdr) {
+	if (elf->phdr) {
 		/* Walk all the program headers to find the PT_INTERP */
 #define SHOW_PT_INTERP(B) \
 		if (elf->elf_class == ELFCLASS ## B) { \
-		unsigned long i; \
-		Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
-		Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \
-		for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
-			if (EGET(phdr[i].p_type) != PT_INTERP) \
-				continue; \
-			*found_interp = 1; \
-			return (be_wewy_wewy_quiet ? NULL : elf->data + EGET(phdr[i].p_offset)); \
-		} \
+			size_t i; \
+			Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
+			Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \
+			for (i = 0; i < EGET(ehdr->e_phnum); ++i) { \
+				if (EGET(phdr[i].p_type) == PT_INTERP) { \
+					offset = EGET(phdr[i].p_offset); \
+					break; \
+				} \
+			} \
 		}
 		SHOW_PT_INTERP(32)
 		SHOW_PT_INTERP(64)
+	} else if (elf->shdr) {
+		/* Use the section headers to find it */
+		void *strtbl_void = elf_findsecbyname(elf, ".interp");
+
+#define SHOW_INTERP(B) \
+		if (elf->elf_class == ELFCLASS ## B) { \
+			Elf ## B ## _Shdr *strtbl = SHDR ## B (strtbl_void); \
+			offset = EGET(strtbl->sh_offset); \
+		}
+		if (strtbl_void) {
+			SHOW_INTERP(32)
+			SHOW_INTERP(64)
+		}
+	}
+
+	/* Validate the pointer even if we don't use it in output */
+	if (offset && offset <= (uint64_t)elf->len) {
+		char *interp = elf->data + offset;
+
+		/* If it isn't a C pointer, it's garbage */
+		if (memchr(interp, 0, elf->len - offset)) {
+			*found_interp = 1;
+			if (!be_wewy_wewy_quiet)
+				return interp;
+		}
 	}
 
 	return NULL;





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2015-02-24  6:58 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2015-02-24  6:58 UTC (permalink / raw
  To: gentoo-commits

vapier      15/02/24 06:58:40

  Modified:             scanelf.c
  Log:
  scanelf: handle corrupted hash chains that have infinite loops

Revision  Changes    Path
1.275                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.275&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.275&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.274&r2=1.275

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.274
retrieving revision 1.275
diff -u -r1.274 -r1.275
--- scanelf.c	22 Feb 2015 02:27:39 -0000	1.274
+++ scanelf.c	24 Feb 2015 06:58:39 -0000	1.275
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.274 2015/02/22 02:27:39 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.275 2015/02/24 06:58:39 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.274 2015/02/22 02:27:39 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.275 2015/02/24 06:58:39 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -289,13 +289,21 @@
 			Elf32_Word *buckets = &hashtbl[2]; \
 			Elf32_Word *chains = &buckets[nbuckets]; \
 			Elf32_Word sym_idx; \
+			Elf32_Word chained; \
 			\
 			for (b = 0; b < nbuckets; ++b) { \
 				if (!buckets[b]) \
 					continue; \
-				for (sym_idx = buckets[b]; sym_idx < nchains && sym_idx; sym_idx = chains[sym_idx]) \
+				for (sym_idx = buckets[b], chained = 0; \
+				     sym_idx < nchains && sym_idx && chained <= nchains; \
+				     sym_idx = chains[sym_idx], ++chained) { \
 					if (max_sym_idx < sym_idx) \
 						max_sym_idx = sym_idx; \
+				} \
+				if (chained > nchains) { \
+					warnf("corrupt ELF bucket"); \
+					break; \
+				} \
 			} \
 			ESET(sym_shdr.sh_size, sym_shdr.sh_entsize * max_sym_idx); \
 		} \





^ permalink raw reply	[flat|nested] 62+ messages in thread

* [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c
@ 2015-02-28 22:59 Mike Frysinger (vapier)
  0 siblings, 0 replies; 62+ messages in thread
From: Mike Frysinger (vapier) @ 2015-02-28 22:59 UTC (permalink / raw
  To: gentoo-commits

vapier      15/02/28 22:59:34

  Modified:             scanelf.c
  Log:
  scanelf: add more range checks to deal with corrupt elfs

Revision  Changes    Path
1.277                pax-utils/scanelf.c

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.277&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.277&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.276&r2=1.277

Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.276
retrieving revision 1.277
diff -u -r1.276 -r1.277
--- scanelf.c	28 Feb 2015 22:57:40 -0000	1.276
+++ scanelf.c	28 Feb 2015 22:59:34 -0000	1.277
@@ -1,13 +1,13 @@
 /*
  * Copyright 2003-2012 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.276 2015/02/28 22:57:40 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.277 2015/02/28 22:59:34 vapier Exp $
  *
  * Copyright 2003-2012 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2004-2012 Mike Frysinger  - <vapier@gentoo.org>
  */
 
-static const char rcsid[] = "$Id: scanelf.c,v 1.276 2015/02/28 22:57:40 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.277 2015/02/28 22:59:34 vapier Exp $";
 const char argv0[] = "scanelf";
 
 #include "paxinc.h"
@@ -275,15 +275,23 @@
 	for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
 		Elf ## B ## _Addr vaddr = EGET(phdr[i].p_vaddr); \
 		Elf ## B ## _Addr filesz = EGET(phdr[i].p_filesz); \
-		offset = EGET(phdr[i].p_offset); \
+		Elf ## B ## _Off hash_offset = offset + (vhash - vaddr); \
 		\
 		if (EGET(phdr[i].p_type) != PT_LOAD) \
 			continue; \
 		\
+		offset = EGET(phdr[i].p_offset); \
+		if (offset >= (uint64_t)elf->len) \
+			goto corrupt_hash; \
+		if (filesz >= (uint64_t)elf->len) \
+			goto corrupt_hash; \
+		if (hash_offset + (sizeof(Elf32_Word) * 4) > (uint64_t)elf->len) \
+			goto corrupt_hash; \
+		\
 		if (vhash >= vaddr && vhash < vaddr + filesz) { \
 			/* Scan the hash table to see how many entries we have */ \
 			Elf32_Word max_sym_idx = 0; \
-			Elf32_Word *hashtbl = elf->vdata + offset + (vhash - vaddr); \
+			Elf32_Word *hashtbl = elf->vdata + hash_offset; \
 			Elf32_Word b, nbuckets = EGET(hashtbl[0]); \
 			Elf32_Word nchains = EGET(hashtbl[1]); \
 			Elf32_Word *buckets = &hashtbl[2]; \
@@ -291,6 +299,17 @@
 			Elf32_Word sym_idx; \
 			Elf32_Word chained; \
 			\
+			if (hash_offset >= (uint64_t)elf->len) \
+				goto corrupt_hash; \
+			if (nbuckets >= UINT32_MAX / 4) \
+				goto corrupt_hash; \
+			if (nchains >= UINT32_MAX / 4) \
+				goto corrupt_hash; \
+			if (nbuckets * 4 > elf->len - offset) \
+				goto corrupt_hash; \
+			if (nchains * 4 > elf->len - offset) \
+				goto corrupt_hash; \
+			\
 			for (b = 0; b < nbuckets; ++b) { \
 				if (!buckets[b]) \
 					continue; \
@@ -300,10 +319,8 @@
 					if (max_sym_idx < sym_idx) \
 						max_sym_idx = sym_idx; \
 				} \
-				if (chained > nchains) { \
-					warnf("corrupt ELF bucket"); \
-					break; \
-				} \
+				if (chained > nchains) \
+					goto corrupt_hash; \
 			} \
 			ESET(sym_shdr.sh_size, sym_shdr.sh_entsize * max_sym_idx); \
 		} \
@@ -321,6 +338,10 @@
 	}
 	GET_SYMTABS_DT(32)
 	GET_SYMTABS_DT(64)
+	return;
+
+ corrupt_hash:
+	warn("%s: ELF hash table is corrupt", elf->filename);
 }
 
 static char *scanelf_file_pax(elfobj *elf, char *found_pax)
@@ -440,8 +461,9 @@
 	} else if (elf->shdr != NULL) { \
 		/* no program headers which means this is prob an object file */ \
 		Elf ## B ## _Shdr *shdr = SHDR ## B (elf->shdr); \
-		Elf ## B ## _Shdr *strtbl = shdr + EGET(ehdr->e_shstrndx); \
-		if ((void*)strtbl > elf->data_end) \
+		uint16_t shstrndx = EGET(ehdr->e_shstrndx); \
+		Elf ## B ## _Shdr *strtbl = shdr + shstrndx; \
+		if (shstrndx >= elf->len - sizeof(*strtbl) || !VALID_SHDR(elf, strtbl)) \
 			goto skip_this_shdr##B; \
 		/* let's flag -w/+x object files since the final ELF will most likely \
 		 * need write access to the stack (who doesn't !?).  so the combined \
@@ -1409,26 +1431,23 @@
 		if (cnt) \
 			cnt = EGET(symtab->sh_size) / cnt; \
 		for (i = 0; i < cnt; ++i) { \
-			if ((void*)sym > elf->data_end) { \
-				warnf("%s: corrupt ELF symbols - aborting", elf->filename); \
+			if ((void *)sym >= elf->data_end - sizeof(*sym)) \
 				goto break_out;	\
-			} \
 			if (sym->st_name) { \
 				/* make sure the symbol name is in acceptable memory range */ \
 				symname = elf->data + EGET(strtab->sh_offset) + EGET(sym->st_name); \
-				if ((void*)symname > elf->data_end) { \
-					warnf("%s: corrupt ELF symbols", elf->filename); \
-					++sym; \
-					continue; \
-				} \
+				if (EGET(sym->st_name) >= (uint64_t)elf->len || \
+				    EGET(strtab->sh_offset) + EGET(sym->st_name) >= (uint64_t)elf->len || \
+				    !memchr(symname, 0, elf->len - EGET(strtab->sh_offset) + EGET(sym->st_name))) \
+					goto break_out; \
 				scanelf_match_symname(elf, found_sym, \
-			                          &ret, &ret_len, symname, \
-			                          ELF##B##_ST_TYPE(EGET(sym->st_info)), \
-			                          ELF##B##_ST_BIND(EGET(sym->st_info)), \
-			                          ELF##B##_ST_VISIBILITY(EGET(sym->st_other)), \
-			                          EGET(sym->st_shndx), \
-			    /* st_size can be 64bit, but no one is really that big, so screw em */ \
-			                          EGET(sym->st_size)); \
+				                      &ret, &ret_len, symname, \
+				                      ELF##B##_ST_TYPE(EGET(sym->st_info)), \
+				                      ELF##B##_ST_BIND(EGET(sym->st_info)), \
+				                      ELF##B##_ST_VISIBILITY(EGET(sym->st_other)), \
+				                      EGET(sym->st_shndx), \
+				/* st_size can be 64bit, but no one is really that big, so screw em */ \
+				                      EGET(sym->st_size)); \
 			} \
 			++sym; \
 		} \
@@ -1437,7 +1456,6 @@
 		FIND_SYM(64)
 	}
 
-break_out:
 	if (be_wewy_wewy_quiet) return NULL;
 
 	if (*find_sym != '*' && *found_sym)
@@ -1446,6 +1464,10 @@
 		return NULL;
 	else
 		return " - ";
+
+ break_out:
+	warnf("%s: corrupt ELF symbols", elf->filename);
+	return NULL;
 }
 
 static const char *scanelf_file_sections(elfobj *elf, char *found_section)





^ permalink raw reply	[flat|nested] 62+ messages in thread

end of thread, other threads:[~2015-02-28 22:59 UTC | newest]

Thread overview: 62+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-15  9:01 [gentoo-commits] gentoo-projects commit in pax-utils: scanelf.c Mike Frysinger (vapier)
  -- strict thread matches above, loose matches on Subject: below --
2015-02-28 22:59 Mike Frysinger (vapier)
2015-02-24  6:58 Mike Frysinger (vapier)
2015-02-22  2:27 Mike Frysinger (vapier)
2015-02-22  1:38 Mike Frysinger (vapier)
2015-02-22  0:10 Mike Frysinger (vapier)
2015-02-21 19:30 Mike Frysinger (vapier)
2014-11-20  1:25 Mike Frysinger (vapier)
2014-11-05  2:02 Mike Frysinger (vapier)
2014-10-19  7:31 Mike Frysinger (vapier)
2014-03-21  5:33 Mike Frysinger (vapier)
2014-03-21  5:27 Mike Frysinger (vapier)
2014-03-20  8:08 Mike Frysinger (vapier)
2014-03-20  8:06 Mike Frysinger (vapier)
2014-01-11  0:28 Mike Frysinger (vapier)
2013-08-14 21:09 Mike Frysinger (vapier)
2013-04-16 16:22 Mike Frysinger (vapier)
2013-04-10 22:27 Mike Frysinger (vapier)
2013-04-08  6:38 Mike Frysinger (vapier)
2013-04-02 21:15 Mike Frysinger (vapier)
2012-11-30 23:25 Mike Frysinger (vapier)
2012-11-10  9:43 Mike Frysinger (vapier)
2012-11-04  8:25 Mike Frysinger (vapier)
2012-11-04  8:23 Mike Frysinger (vapier)
2012-11-04  7:48 Mike Frysinger (vapier)
2012-11-04  6:55 Mike Frysinger (vapier)
2012-08-04  6:08 Mike Frysinger (vapier)
2012-04-29  6:21 Mike Frysinger (vapier)
2012-04-29  5:41 Mike Frysinger (vapier)
2012-01-25  1:58 Mike Frysinger (vapier)
2012-01-23 23:48 Mike Frysinger (vapier)
2012-01-23 22:28 Mike Frysinger (vapier)
2011-12-21 22:17 Mike Frysinger (vapier)
2011-12-21 22:00 Mike Frysinger (vapier)
2011-12-21 17:34 Mike Frysinger (vapier)
2011-12-13  5:12 Mike Frysinger (vapier)
2011-10-13  4:49 Mike Frysinger (vapier)
2011-09-27 22:20 Mike Frysinger (vapier)
2011-09-27 19:56 Mike Frysinger (vapier)
2011-09-27 19:29 Mike Frysinger (vapier)
2011-09-27 19:21 Mike Frysinger (vapier)
2011-09-27 19:20 Mike Frysinger (vapier)
2011-09-27 17:28 Mike Frysinger (vapier)
2011-08-08  1:56 Mike Frysinger (vapier)
2011-07-30 17:08 Ned Ludd (solar)
2010-12-06 20:43 Mike Frysinger (vapier)
2010-01-15 11:56 Mike Frysinger (vapier)
2009-12-20 20:25 Mike Frysinger (vapier)
2009-12-01 10:18 Mike Frysinger (vapier)
2009-03-15  9:13 Mike Frysinger (vapier)
2009-03-15  8:53 Mike Frysinger (vapier)
2008-12-30 13:38 Mike Frysinger (vapier)
2008-12-30 12:38 Mike Frysinger (vapier)
2008-12-10 20:06 Fabian Groffen (grobian)
2008-12-10 20:05 Fabian Groffen (grobian)
2008-11-17 18:09 Diego Petteno (flameeyes)
2008-11-17 18:03 Diego Petteno (flameeyes)
2008-10-22 17:03 Diego Petteno (flameeyes)
2008-10-22 15:20 Diego Petteno (flameeyes)
2008-09-29  6:05 Mike Frysinger (vapier)
2008-09-29  6:03 Mike Frysinger (vapier)
2008-09-29  6:01 Mike Frysinger (vapier)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox