/[gentoo-projects]/pax-utils/scanelf.c
Gentoo

Diff of /pax-utils/scanelf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.153 Revision 1.154
1/* 1/*
2 * Copyright 2003-2006 Gentoo Foundation 2 * Copyright 2003-2006 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.153 2006/05/17 21:45:20 solar Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.154 2006/06/03 18:25:18 solar Exp $
5 * 5 *
6 * Copyright 2003-2006 Ned Ludd - <solar@gentoo.org> 6 * Copyright 2003-2006 Ned Ludd - <solar@gentoo.org>
7 * Copyright 2004-2006 Mike Frysinger - <vapier@gentoo.org> 7 * Copyright 2004-2006 Mike Frysinger - <vapier@gentoo.org>
8 */ 8 */
9 9
10#include "paxinc.h" 10#include "paxinc.h"
11 11
12static const char *rcsid = "$Id: scanelf.c,v 1.153 2006/05/17 21:45:20 solar Exp $"; 12static const char *rcsid = "$Id: scanelf.c,v 1.154 2006/06/03 18:25:18 solar Exp $";
13#define argv0 "scanelf" 13#define argv0 "scanelf"
14 14
15#define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+') 15#define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+')
16 16
17#define do_state(option, flag) \ 17#define do_state(option, flag) \
748 continue; 748 continue;
749 strncpy(buf, strs + libent[fd].liboffset, sizeof(buf)); 749 strncpy(buf, strs + libent[fd].liboffset, sizeof(buf));
750 } 750 }
751 return buf; 751 return buf;
752} 752}
753#elif defined(__NetBSD__)
754static char *lookup_cache_lib(elfobj *elf, char *fname)
755{
756 static char buf[__PAX_UTILS_PATH_MAX] = "";
757 static struct stat st;
753 758
759 char **ldpath;
760 for (ldpath = ldpaths; *ldpath != NULL; ldpath++) {
761 if ((unsigned) snprintf(buf, sizeof(buf), "%s/%s", *ldpath, fname) >= sizeof(buf))
762 continue; /* if the pathname is too long, or something went wrong, ignore */
763
764 if (stat(buf, &st) != 0)
765 continue; /* if the lib doesn't exist in *ldpath, look further */
766
767 /* NetBSD doesn't actually do sanity checks, it just loads the file
768 * and if that doesn't work, continues looking in other directories.
769 * This cannot easily be safely emulated, unfortunately. For now,
770 * just assume that if it exists, it's a valid library. */
771
772 return buf;
773 }
774
775 /* not found in any path */
776 return NULL;
777}
754#else 778#else
755#warning Cache support not implemented for your target 779#warning Cache support not implemented for your target
756static char *lookup_cache_lib(elfobj *elf, char *fname) 780static char *lookup_cache_lib(elfobj *elf, char *fname)
757{ 781{
758 return NULL; 782 return NULL;
1371 if (fp != stdin) 1395 if (fp != stdin)
1372 fclose(fp); 1396 fclose(fp);
1373 return 0; 1397 return 0;
1374} 1398}
1375 1399
1376#if defined(__GLIBC__) || defined(__UCLIBC__) 1400#if defined(__GLIBC__) || defined(__UCLIBC__) || defined(__NetBSD__)
1377 1401
1378static int load_ld_cache_config(int i, const char *fname) 1402static int load_ld_cache_config(int i, const char *fname)
1379{ 1403{
1380 FILE *fp = NULL; 1404 FILE *fp = NULL;
1381 char *p; 1405 char *p;
1390 while ((fgets(path, __PAX_UTILS_PATH_MAX, fp)) != NULL) { 1414 while ((fgets(path, __PAX_UTILS_PATH_MAX, fp)) != NULL) {
1391 if ((p = strrchr(path, '\r')) != NULL) 1415 if ((p = strrchr(path, '\r')) != NULL)
1392 *p = 0; 1416 *p = 0;
1393 if ((p = strchr(path, '\n')) != NULL) 1417 if ((p = strchr(path, '\n')) != NULL)
1394 *p = 0; 1418 *p = 0;
1419#ifdef __linux__
1395 // recursive includes of the same file will make this segfault. 1420 // recursive includes of the same file will make this segfault.
1396 if ((memcmp(path, "include", 7) == 0) && isblank(path[7])) { 1421 if ((memcmp(path, "include", 7) == 0) && isblank(path[7])) {
1397 glob64_t gl; 1422 glob64_t gl;
1398 size_t x; 1423 size_t x;
1399 char gpath[__PAX_UTILS_PATH_MAX]; 1424 char gpath[__PAX_UTILS_PATH_MAX];
1419 globfree64 (&gl); 1444 globfree64 (&gl);
1420 continue; 1445 continue;
1421 } else 1446 } else
1422 abort(); 1447 abort();
1423 } 1448 }
1449#endif
1424 if (*path != '/') 1450 if (*path != '/')
1425 continue; 1451 continue;
1426 1452
1427 ldpaths[i++] = xstrdup(path); 1453 ldpaths[i++] = xstrdup(path);
1428 1454

Legend:
Removed from v.1.153  
changed lines
  Added in v.1.154

  ViewVC Help
Powered by ViewVC 1.1.20