| 1 | /* |
1 | /* |
| 2 | * Copyright 2003-2007 Gentoo Foundation |
2 | * Copyright 2003-2007 Gentoo Foundation |
| 3 | * Distributed under the terms of the GNU General Public License v2 |
3 | * Distributed under the terms of the GNU General Public License v2 |
| 4 | * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.218 2010/01/15 11:56:15 vapier Exp $ |
4 | * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.219 2010/12/06 20:43:48 vapier Exp $ |
| 5 | * |
5 | * |
| 6 | * Copyright 2003-2007 Ned Ludd - <solar@gentoo.org> |
6 | * Copyright 2003-2007 Ned Ludd - <solar@gentoo.org> |
| 7 | * Copyright 2004-2007 Mike Frysinger - <vapier@gentoo.org> |
7 | * Copyright 2004-2007 Mike Frysinger - <vapier@gentoo.org> |
| 8 | */ |
8 | */ |
| 9 | |
9 | |
| 10 | static const char *rcsid = "$Id: scanelf.c,v 1.218 2010/01/15 11:56:15 vapier Exp $"; |
10 | static const char *rcsid = "$Id: scanelf.c,v 1.219 2010/12/06 20:43:48 vapier Exp $"; |
| 11 | const char * const argv0 = "scanelf"; |
11 | const char * const argv0 = "scanelf"; |
| 12 | |
12 | |
| 13 | #include "paxinc.h" |
13 | #include "paxinc.h" |
| 14 | |
14 | |
| 15 | #define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+') |
15 | #define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+') |
| … | |
… | |
| 1589 | while ((fgets(path, __PAX_UTILS_PATH_MAX, fp)) != NULL) { |
1589 | while ((fgets(path, __PAX_UTILS_PATH_MAX, fp)) != NULL) { |
| 1590 | if ((p = strrchr(path, '\r')) != NULL) |
1590 | if ((p = strrchr(path, '\r')) != NULL) |
| 1591 | *p = 0; |
1591 | *p = 0; |
| 1592 | if ((p = strchr(path, '\n')) != NULL) |
1592 | if ((p = strchr(path, '\n')) != NULL) |
| 1593 | *p = 0; |
1593 | *p = 0; |
| 1594 | #ifdef __linux__ |
1594 | |
| 1595 | /* recursive includes of the same file will make this segfault. */ |
1595 | /* recursive includes of the same file will make this segfault. */ |
| 1596 | if ((memcmp(path, "include", 7) == 0) && isblank(path[7])) { |
1596 | if ((memcmp(path, "include", 7) == 0) && isblank(path[7])) { |
| 1597 | glob64_t gl; |
1597 | glob_t gl; |
| 1598 | size_t x; |
1598 | size_t x; |
| 1599 | char gpath[__PAX_UTILS_PATH_MAX]; |
1599 | char gpath[__PAX_UTILS_PATH_MAX]; |
| 1600 | |
1600 | |
| 1601 | memset(gpath, 0, sizeof(gpath)); |
1601 | memset(gpath, 0, sizeof(gpath)); |
| 1602 | |
1602 | |
| 1603 | if (path[8] != '/') |
1603 | if (path[8] != '/') |
| 1604 | snprintf(gpath, sizeof(gpath), "/etc/%s", &path[8]); |
1604 | snprintf(gpath, sizeof(gpath), "/etc/%s", &path[8]); |
| 1605 | else |
1605 | else |
| 1606 | strncpy(gpath, &path[8], sizeof(gpath)); |
1606 | strncpy(gpath, &path[8], sizeof(gpath)); |
| 1607 | |
1607 | |
| 1608 | if ((glob64(gpath, 0, NULL, &gl)) == 0) { |
1608 | if (glob(gpath, 0, NULL, &gl) == 0) { |
| 1609 | for (x = 0; x < gl.gl_pathc; ++x) { |
1609 | for (x = 0; x < gl.gl_pathc; ++x) { |
| 1610 | /* try to avoid direct loops */ |
1610 | /* try to avoid direct loops */ |
| 1611 | if (strcmp(gl.gl_pathv[x], fname) == 0) |
1611 | if (strcmp(gl.gl_pathv[x], fname) == 0) |
| 1612 | continue; |
1612 | continue; |
| 1613 | i = load_ld_cache_config(i, gl.gl_pathv[x]); |
1613 | i = load_ld_cache_config(i, gl.gl_pathv[x]); |
| 1614 | if (i + 1 >= ARRAY_SIZE(ldpaths)) { |
1614 | if (i + 1 >= ARRAY_SIZE(ldpaths)) { |
| 1615 | globfree64(&gl); |
1615 | globfree(&gl); |
| 1616 | return i; |
1616 | return i; |
| 1617 | } |
1617 | } |
| 1618 | } |
1618 | } |
| 1619 | globfree64 (&gl); |
1619 | globfree(&gl); |
| 1620 | continue; |
1620 | continue; |
| 1621 | } |
1621 | } |
| 1622 | } |
1622 | } |
| 1623 | #endif |
1623 | |
| 1624 | if (*path != '/') |
1624 | if (*path != '/') |
| 1625 | continue; |
1625 | continue; |
| 1626 | |
1626 | |
| 1627 | ldpaths[i++] = xstrdup(path); |
1627 | ldpaths[i++] = xstrdup(path); |
| 1628 | |
1628 | |