/[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.82 Revision 1.83
1/* 1/*
2 * Copyright 2003-2005 Gentoo Foundation 2 * Copyright 2003-2005 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.82 2005/06/19 05:39:31 vapier Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.83 2005/06/22 17:43:12 solar Exp $
5 * 5 *
6 ******************************************************************** 6 ********************************************************************
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as 8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the 9 * published by the Free Software Foundation; either version 2 of the
33#include <dirent.h> 33#include <dirent.h>
34#include <getopt.h> 34#include <getopt.h>
35#include <assert.h> 35#include <assert.h>
36#include "paxelf.h" 36#include "paxelf.h"
37 37
38static const char *rcsid = "$Id: scanelf.c,v 1.82 2005/06/19 05:39:31 vapier Exp $"; 38static const char *rcsid = "$Id: scanelf.c,v 1.83 2005/06/22 17:43:12 solar Exp $";
39#define argv0 "scanelf" 39#define argv0 "scanelf"
40 40
41#define IS_MODIFIER(c) (c == '%' || c == '#') 41#define IS_MODIFIER(c) (c == '%' || c == '#')
42 42
43 43
344 if (!*found_textrels) 344 if (!*found_textrels)
345 warnf("ELF %s has TEXTREL markings but doesnt appear to have any real TEXTREL's !?", elf->filename); 345 warnf("ELF %s has TEXTREL markings but doesnt appear to have any real TEXTREL's !?", elf->filename);
346 346
347 return NULL; 347 return NULL;
348} 348}
349
350static void rpath_security_checks(elfobj *, char *);
351static void rpath_security_checks(elfobj *elf, char *item) {
352 struct stat st;
353 switch(*item) {
354 case 0:
355 warnf("Security problem NULL RPATH in %s", elf->filename);
356 break;
357 case '/': break;
358 case '$':
359 if (fstat(elf->fd, &st) != (-1))
360 if ((st.st_mode & S_ISUID) || (st.st_mode & S_ISGID))
361 warnf("Security problem with RPATH='%s' in %s with mode set of %o",
362 item, elf->filename, st.st_mode & 07777);
363 break;
364 default:
365 warnf("Maybe? sec problem with RPATH='%s' in %s", item, elf->filename);
366 break;
367 }
368}
369
349static void scanelf_file_rpath(elfobj *elf, char *found_rpath, char **ret, size_t *ret_len) 370static void scanelf_file_rpath(elfobj *elf, char *found_rpath, char **ret, size_t *ret_len)
350{ 371{
351 unsigned long i, s; 372 unsigned long i, s;
352 char *rpath, *runpath, **r; 373 char *rpath, *runpath, **r;
353 void *strtbl_void; 374 void *strtbl_void;
395 /* note that we only 'chop' off leading known paths. */ \ 416 /* note that we only 'chop' off leading known paths. */ \
396 /* since *r is read-only memory, we can only move the ptr forward. */ \ 417 /* since *r is read-only memory, we can only move the ptr forward. */ \
397 start = *r; \ 418 start = *r; \
398 /* scan each path in : delimited list */ \ 419 /* scan each path in : delimited list */ \
399 while (start) { \ 420 while (start) { \
421 rpath_security_checks(elf, start); \
400 end = strchr(start, ':'); \ 422 end = strchr(start, ':'); \
401 len = (end ? abs(end - start) : strlen(start)); \ 423 len = (end ? abs(end - start) : strlen(start)); \
402 for (s = 0; ldpaths[s]; ++s) { \ 424 for (s = 0; ldpaths[s]; ++s) { \
403 if (!strncmp(ldpaths[s], start, len) && !ldpaths[s][len]) { \ 425 if (!strncmp(ldpaths[s], start, len) && !ldpaths[s][len]) { \
404 *r = (end ? end + 1 : NULL); \ 426 *r = (end ? end + 1 : NULL); \

Legend:
Removed from v.1.82  
changed lines
  Added in v.1.83

  ViewVC Help
Powered by ViewVC 1.1.20