Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 86470 Details for
Bug 131779
QA_TEXTRELS support
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
scanelf modification to do the qa stuff
pax-utils-qa.patch (text/plain), 6.26 KB, created by
Kevin F. Quinn (RETIRED)
on 2006-05-09 04:09:18 UTC
(
hide
)
Description:
scanelf modification to do the qa stuff
Filename:
MIME Type:
Creator:
Kevin F. Quinn (RETIRED)
Created:
2006-05-09 04:09:18 UTC
Size:
6.26 KB
patch
obsolete
>Index: porting.h >=================================================================== >RCS file: /var/cvsroot/gentoo-projects/pax-utils/porting.h,v >retrieving revision 1.15 >diff -u -r1.15 porting.h >--- porting.h 19 Mar 2006 02:41:17 -0000 1.15 >+++ porting.h 9 May 2006 10:52:14 -0000 >@@ -28,6 +28,7 @@ > #include <libgen.h> > #include <ctype.h> > #include <pwd.h> >+#include <fnmatch.h> > > #include <sys/mman.h> > #include "elf.h" >Index: scanelf.c >=================================================================== >RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v >retrieving revision 1.141 >diff -u -r1.141 scanelf.c >--- scanelf.c 23 Apr 2006 15:24:38 -0000 1.141 >+++ scanelf.c 9 May 2006 10:52:14 -0000 >@@ -31,6 +31,7 @@ > > > /* 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); >@@ -39,6 +40,8 @@ > static void scanelf_ldpath(void); > static void scanelf_envpath(void); > static void usage(int status); >+static char **getpathenv(const char *envvar); >+static void parseenv(void); > static void parseargs(int argc, char *argv[]); > static char *xstrdup(const char *s); > static void *xmalloc(size_t size); >@@ -78,11 +81,75 @@ > static char gmatch = 0; > static char use_ldcache = 0; > >+static char **qa_textrels = NULL; >+static char **qa_execstack = NULL; >+ > int match_bits = 0; > caddr_t ldcache = 0; > size_t ldcache_size = 0; > unsigned long setpax = 0UL; > >+/* utility funcs */ >+static char *xstrdup(const char *s) >+{ >+ char *ret = strdup(s); >+ if (!ret) err("Could not strdup(): %s", strerror(errno)); >+ return ret; >+} >+static void *xmalloc(size_t size) >+{ >+ void *ret = malloc(size); >+ if (!ret) err("Could not malloc() %li bytes", (unsigned long)size); >+ return ret; >+} >+static void xstrncat(char **dst, const char *src, size_t *curr_len, size_t n) >+{ >+ size_t new_len; >+ >+ new_len = strlen(*dst) + strlen(src); >+ if (*curr_len <= new_len) { >+ *curr_len = new_len + (*curr_len / 2); >+ *dst = realloc(*dst, *curr_len); >+ if (!*dst) >+ err("could not realloc() %li bytes", (unsigned long)*curr_len); >+ } >+ >+ if (n) >+ strncat(*dst, src, n); >+ else >+ strcat(*dst, src); >+} >+static inline void xchrcat(char **dst, const char append, size_t *curr_len) >+{ >+ static char my_app[2]; >+ my_app[0] = append; >+ my_app[1] = '\0'; >+ xstrcat(dst, my_app, curr_len); >+} >+ >+/* Match filename against entries in matchlist, return TRUE >+ * if the file is listed */ >+static int file_matches_list(const char *filename, char **matchlist) { >+ char **file; >+ char *match; >+ char buf[__PAX_UTILS_PATH_MAX]; >+ if (matchlist!=NULL) { >+ for (file=matchlist; >+ *file!=NULL; >+ file++) { >+ if (search_path) { >+ snprintf(buf,__PAX_UTILS_PATH_MAX,"%s%s",search_path,*file); >+ match=buf; >+ } else { >+ match=file; >+ } >+ if (fnmatch(match, filename, 0) == 0) >+ return 1; /* TRUE */ >+ } >+ } >+ return 0; /* FALSE */ >+} >+ > /* sub-funcs for scanelf_file() */ > static void scanelf_file_get_symtabs(elfobj *elf, void **sym, void **tab) > { >@@ -200,9 +267,11 @@ > for (i = 0; i < EGET(ehdr->e_phnum); ++i) { \ > if (EGET(phdr[i].p_type) == PT_GNU_STACK) { \ > if (multi_stack++) warnf("%s: multiple PT_GNU_STACK's !?", elf->filename); \ >- found = found_phdr; \ >- offset = 0; \ >- check_flags = PF_X; \ >+ if (!file_matches_list(elf->filename, qa_execstack)) {\ >+ found = found_phdr; \ >+ offset = 0; \ >+ check_flags = PF_X; \ >+ } else continue; \ > } else if (EGET(phdr[i].p_type) == PT_GNU_RELRO) { \ > if (multi_relro++) warnf("%s: multiple PT_GNU_RELRO's !?", elf->filename); \ > found = found_relro; \ >@@ -271,6 +340,7 @@ > else > return ret; > } >+ > static const char *scanelf_file_textrel(elfobj *elf, char *found_textrel) > { > static const char *ret = "TEXTREL"; >@@ -278,6 +348,8 @@ > > if (!show_textrel && !show_textrels) return NULL; > >+ if (file_matches_list(elf->filename, qa_textrels)) return NULL; >+ > if (elf->phdr) { > #define SHOW_TEXTREL(B) \ > if (elf->elf_class == ELFCLASS ## B) { \ >@@ -1253,7 +1325,7 @@ > (unsigned long)len, (unsigned long)sizeof(buf)); > continue; > } >- sprintf(buf, "%s/%s", path, dentry->d_name); >+ sprintf(buf, "%s%s%s", path, path[pathlen-1]=='/'?"":"/", dentry->d_name); > if (lstat(buf, &st) != -1) { > if (S_ISREG(st.st_mode)) > scanelf_file(buf); >@@ -1765,42 +1837,45 @@ > > > >-/* utility funcs */ >-static char *xstrdup(const char *s) >-{ >- char *ret = strdup(s); >- if (!ret) err("Could not strdup(): %s", strerror(errno)); >- return ret; >-} >-static void *xmalloc(size_t size) >-{ >- void *ret = malloc(size); >- if (!ret) err("Could not malloc() %li bytes", (unsigned long)size); >- return ret; >-} >-static void xstrncat(char **dst, const char *src, size_t *curr_len, size_t n) >-{ >- size_t new_len; >- >- new_len = strlen(*dst) + strlen(src); >- if (*curr_len <= new_len) { >- *curr_len = new_len + (*curr_len / 2); >- *dst = realloc(*dst, *curr_len); >- if (!*dst) >- err("could not realloc() %li bytes", (unsigned long)*curr_len); >- } >- >- if (n) >- strncat(*dst, src, n); >- else >- strcat(*dst, src); >-} >-static inline void xchrcat(char **dst, const char append, size_t *curr_len) >-{ >- static char my_app[2]; >- my_app[0] = append; >- my_app[1] = '\0'; >- xstrcat(dst, my_app, curr_len); >+static char **getpathenv(const char *envvar) { >+ char **envvals=NULL; >+ char *env=getenv(envvar); >+ char *saveptr=NULL; >+ int nentries; >+ char *s; >+ int nentry; >+ >+ if (env==NULL) return NULL; >+ >+ env=xstrdup(env); >+ if (env==NULL) return NULL; >+ >+ /* Count number of ":"-separated entries in env */ >+ nentries=1; >+ for (s=env; *s>0; s++) >+ if (*s==':') >+ nentries++; >+ >+ /* Allocate space for 'nentries' + 1 for terminating NULL */ >+ envvals=(char **)xmalloc(sizeof(char *)*(nentries+1)); >+ if (envvals==NULL) return NULL; >+ >+ nentry=0; >+ for (s=strtok_r(env, ":", &saveptr); >+ s!=NULL; >+ s=strtok_r(NULL, ":", &saveptr)) { >+ envvals[nentry++]=s; >+ } >+ envvals[nentry]=NULL; >+ /* sanity check */ >+ assert(nentry==nentries); >+ >+ return envvals; >+} >+ >+static void parseenv() { >+ qa_textrels=getpathenv("QA_TEXTRELS"); >+ qa_execstack=getpathenv("QA_EXECSTACK"); > } > > >@@ -1809,6 +1884,7 @@ > { > if (argc < 2) > usage(EXIT_FAILURE); >+ parseenv(); > parseargs(argc, argv); > fclose(stdout); > #ifdef __BOUNDS_CHECKING_ON
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 131779
:
85819
|
85820
|
85978
|
85979
|
86077
|
86079
|
86099
|
86124
|
86246
|
86247
|
86248
|
86249
|
86470
|
86474
|
86667
|
86668
|
86696
|
86697
|
86698
|
86699
|
87360
|
87361
|
87405