/[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.234 Revision 1.235
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.234 2011/10/13 04:49:30 vapier Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.235 2011/12/13 05:12:14 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
10static const char rcsid[] = "$Id: scanelf.c,v 1.234 2011/10/13 04:49:30 vapier Exp $"; 10static const char rcsid[] = "$Id: scanelf.c,v 1.235 2011/12/13 05:12:14 vapier Exp $";
11const char argv0[] = "scanelf"; 11const char 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 == '+')
1534 elfobj *elf; 1534 elfobj *elf;
1535 1535
1536 /* verify this is real ELF */ 1536 /* verify this is real ELF */
1537 if ((elf = _readelf_fd(filename, fd, len, !fix_elf)) == NULL) { 1537 if ((elf = _readelf_fd(filename, fd, len, !fix_elf)) == NULL) {
1538 if (be_verbose > 2) printf("%s: not an ELF\n", filename); 1538 if (be_verbose > 2) printf("%s: not an ELF\n", filename);
1539 return ret; 1539 return 2;
1540 } 1540 }
1541 switch (match_bits) { 1541 switch (match_bits) {
1542 case 32: 1542 case 32:
1543 if (elf->elf_class != ELFCLASS32) 1543 if (elf->elf_class != ELFCLASS32)
1544 goto label_done; 1544 goto label_done;
1625 } 1625 }
1626 fd = openat(dir_fd, filename, (fix_elf ? O_RDWR : O_RDONLY) | O_CLOEXEC); 1626 fd = openat(dir_fd, filename, (fix_elf ? O_RDWR : O_RDONLY) | O_CLOEXEC);
1627 if (fd == -1) 1627 if (fd == -1)
1628 return 1; 1628 return 1;
1629 1629
1630 if (scanelf_elf(filename, fd, st->st_size) == 1 && scan_archives) 1630 if (scanelf_elf(filename, fd, st->st_size) == 2) {
1631 /* if it isn't an ELF, maybe it's an .a archive */ 1631 /* if it isn't an ELF, maybe it's an .a archive */
1632 if (scan_archives)
1632 scanelf_archive(filename, fd, st->st_size); 1633 scanelf_archive(filename, fd, st->st_size);
1633 1634
1634 /* XXX: unreadelf() implicitly closes its fd */ 1635 /*
1636 * unreadelf() implicitly closes its fd, so only close it
1637 * when we are returning it in the non-ELF case
1638 */
1635 close(fd); 1639 close(fd);
1640 }
1641
1636 return 0; 1642 return 0;
1637} 1643}
1638 1644
1639/* scan a directory for ET_EXEC files and print when we find one */ 1645/* scan a directory for ET_EXEC files and print when we find one */
1640static int scanelf_dirat(int dir_fd, const char *path) 1646static int scanelf_dirat(int dir_fd, const char *path)

Legend:
Removed from v.1.234  
changed lines
  Added in v.1.235

  ViewVC Help
Powered by ViewVC 1.1.20