| 1 | /* |
1 | /* |
| 2 | * Copyright 2003 Ned Ludd <solar@gentoo.org> |
2 | * Copyright 2003 Ned Ludd <solar@gentoo.org> |
| 3 | * Copyright 1999-2005 Gentoo Foundation |
3 | * Copyright 1999-2005 Gentoo Foundation |
| 4 | * Distributed under the terms of the GNU General Public License v2 |
4 | * Distributed under the terms of the GNU General Public License v2 |
| 5 | * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.29 2005/04/05 04:25:54 vapier Exp $ |
5 | * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.30 2005/04/05 16:15:31 solar Exp $ |
| 6 | * |
6 | * |
| 7 | ******************************************************************** |
7 | ******************************************************************** |
| 8 | * This program is free software; you can redistribute it and/or |
8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of the |
10 | * published by the Free Software Foundation; either version 2 of the |
| … | |
… | |
| 33 | #include <getopt.h> |
33 | #include <getopt.h> |
| 34 | #include <assert.h> |
34 | #include <assert.h> |
| 35 | |
35 | |
| 36 | #include "paxelf.h" |
36 | #include "paxelf.h" |
| 37 | |
37 | |
| 38 | static const char *rcsid = "$Id: scanelf.c,v 1.29 2005/04/05 04:25:54 vapier Exp $"; |
38 | static const char *rcsid = "$Id: scanelf.c,v 1.30 2005/04/05 16:15:31 solar Exp $"; |
| 39 | |
39 | |
| 40 | |
40 | |
| 41 | /* helper functions for showing errors */ |
41 | /* helper functions for showing errors */ |
| 42 | #define argv0 "scanelf" /*((*argv != NULL) ? argv[0] : __FILE__ "\b\b")*/ |
42 | #define argv0 "scanelf" /*((*argv != NULL) ? argv[0] : __FILE__ "\b\b")*/ |
| 43 | #define warn(fmt, args...) \ |
43 | #define warn(fmt, args...) \ |
| … | |
… | |
| 319 | if ((fp = fopen("/etc/ld.so.conf", "r")) == NULL) |
319 | if ((fp = fopen("/etc/ld.so.conf", "r")) == NULL) |
| 320 | err("Unable to open ld.so.conf: %s", strerror(errno)); |
320 | err("Unable to open ld.so.conf: %s", strerror(errno)); |
| 321 | |
321 | |
| 322 | scan_l = scan_ul = scan_ull = 0; |
322 | scan_l = scan_ul = scan_ull = 0; |
| 323 | |
323 | |
| 324 | path = malloc(_POSIX_PATH_MAX); |
324 | if ((path = malloc(_POSIX_PATH_MAX)) == NULL) { |
|
|
325 | warn("Can not malloc() memory for ldpath scanning"); |
|
|
326 | return; |
|
|
327 | } |
| 325 | while ((fgets(path, _POSIX_PATH_MAX, fp)) != NULL) |
328 | while ((fgets(path, _POSIX_PATH_MAX, fp)) != NULL) |
| 326 | if (*path == '/') { |
329 | if (*path == '/') { |
| 327 | if ((p = strrchr(path, '\r')) != NULL) |
330 | if ((p = strrchr(path, '\r')) != NULL) |
| 328 | *p = 0; |
331 | *p = 0; |
| 329 | if ((p = strrchr(path, '\n')) != NULL) |
332 | if ((p = strrchr(path, '\n')) != NULL) |