diff options
-rw-r--r-- | utils/chroot_realpath.c | 14 | ||||
-rw-r--r-- | utils/ldd.c | 25 |
2 files changed, 17 insertions, 22 deletions
diff --git a/utils/chroot_realpath.c b/utils/chroot_realpath.c index 0785c6c5b..ff1d85d7f 100644 --- a/utils/chroot_realpath.c +++ b/utils/chroot_realpath.c @@ -1,5 +1,5 @@ /* - * chroot_realpath.c -- reslove pathname as if inside chroot + * chroot_realpath.c -- resolve pathname as if inside chroot * Based on realpath.c Copyright (C) 1993 Rick Sladkey <jrs@world.std.com> * * This program is free software; you can redistribute it and/or @@ -32,10 +32,6 @@ #include <limits.h> /* for PATH_MAX */ #include <sys/param.h> /* for MAXPATHLEN */ #include <errno.h> -#ifndef __set_errno -#define __set_errno(val) ((errno) = (val)) -#endif - #include <sys/stat.h> /* for S_IFLNK */ #ifndef PATH_MAX @@ -67,7 +63,7 @@ char *chroot_realpath(const char *chroot, const char *path, chroot_len = strlen(chroot); if (chroot_len + strlen(path) >= PATH_MAX - 3) { - __set_errno(ENAMETOOLONG); + errno = ENAMETOOLONG; return NULL; } @@ -112,7 +108,7 @@ char *chroot_realpath(const char *chroot, const char *path, /* Safely copy the next pathname component. */ while (*path != '\0' && *path != '/') { if (path > max_path) { - __set_errno(ENAMETOOLONG); + errno = ENAMETOOLONG; return NULL; } *new_path++ = *path++; @@ -123,7 +119,7 @@ char *chroot_realpath(const char *chroot, const char *path, #ifdef S_IFLNK /* Protect against infinite loops. */ if (readlinks++ > MAX_READLINKS) { - __set_errno(ELOOP); + errno = ELOOP; return NULL; } /* See if latest pathname component is a symlink. */ @@ -148,7 +144,7 @@ char *chroot_realpath(const char *chroot, const char *path, while (*(--new_path) != '/') ; /* Safe sex check. */ if (strlen(path) + n >= PATH_MAX - 2) { - __set_errno(ENAMETOOLONG); + errno = ENAMETOOLONG; return NULL; } /* Insert symlink contents into path. */ diff --git a/utils/ldd.c b/utils/ldd.c index 4a05d32d9..17bab2079 100644 --- a/utils/ldd.c +++ b/utils/ldd.c @@ -22,7 +22,6 @@ #include <sys/mman.h> #include <sys/stat.h> #include <sys/types.h> -#include <sys/types.h> #include <sys/wait.h> #include "bswap.h" @@ -151,10 +150,10 @@ struct library { char *path; struct library *next; }; -struct library *lib_list = NULL; -char not_found[] = "not found"; -char *interp_name = NULL; -char *interp_dir = NULL; +static struct library *lib_list = NULL; +static char not_found[] = "not found"; +static char *interp_name = NULL; +static char *interp_dir = NULL; static int byteswap; static int interpreter_already_found = 0; @@ -526,7 +525,7 @@ static int add_library(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic, int is_setuid, char tmp1++; } if (strcmp(tmp2, s) == 0) { - //printf("find_elf_interpreter is skipping '%s' (already in list)\n", cur->name); + /*printf("find_elf_interpreter is skipping '%s' (already in list)\n", cur->name); */ return 0; } } @@ -544,7 +543,7 @@ static int add_library(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic, int is_setuid, char /* Now try and locate where this library might be living... */ locate_library_file(ehdr, dynamic, is_setuid, newlib); - //printf("add_library is adding '%s' to '%s'\n", newlib->name, newlib->path); + /*printf("add_library is adding '%s' to '%s'\n", newlib->name, newlib->path); */ if (!lib_list) { lib_list = newlib; } else { @@ -597,7 +596,7 @@ static struct library *find_elf_interpreter(ElfW(Ehdr) *ehdr) for (cur = lib_list; cur; cur = cur->next) { /* Check if this library is already in the list */ if (strcmp(cur->name, tmp1) == 0) { - //printf("find_elf_interpreter is replacing '%s' (already in list)\n", cur->name); + /*printf("find_elf_interpreter is replacing '%s' (already in list)\n", cur->name); */ newlib = cur; free(newlib->name); if (newlib->path != not_found) { @@ -619,7 +618,7 @@ static struct library *find_elf_interpreter(ElfW(Ehdr) *ehdr) newlib->next = NULL; #if 0 - //printf("find_elf_interpreter is adding '%s' to '%s'\n", newlib->name, newlib->path); + /*printf("find_elf_interpreter is adding '%s' to '%s'\n", newlib->name, newlib->path); */ if (!lib_list) { lib_list = newlib; } else { @@ -760,8 +759,8 @@ int main(int argc, char **argv) struct library *cur; if (argc < 2) { - fprintf(stderr, "ldd: missing file arguments\n"); - fprintf(stderr, "Try `ldd --help' for more information.\n"); + fprintf(stderr, "ldd: missing file arguments\n" + "Try `ldd --help' for more information.\n"); exit(EXIT_FAILURE); } if (argc > 2) @@ -776,8 +775,8 @@ int main(int argc, char **argv) } if (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0) { - fprintf(stderr, "Usage: ldd [OPTION]... FILE...\n"); - fprintf(stderr, "\t--help\t\tprint this help and exit\n"); + fprintf(stderr, "Usage: ldd [OPTION]... FILE...\n" + "\t--help\t\tprint this help and exit\n"); exit(EXIT_SUCCESS); } |