X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gnu%2Fopenat-proc.c;h=5e0d9d7965ee45144d76cf22b3f0b02736a6818e;hb=1a44d77d50f4fb37c0410eed04b82303624ea2ec;hp=9b4d9578b3227543dff965208b14a147622c1edc;hpb=dda6367c9eac71da8f2ab1c60b3df60f19ce4755;p=debian%2Ftar diff --git a/gnu/openat-proc.c b/gnu/openat-proc.c index 9b4d9578..5e0d9d79 100644 --- a/gnu/openat-proc.c +++ b/gnu/openat-proc.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Create /proc/self/fd-related names for subfiles of open directories. - Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,13 +28,12 @@ #include #include +#include #include #include -#include "dirname.h" #include "intprops.h" #include "same-inode.h" -#include "xalloc.h" /* The results of open() in this file are not used with fchdir, and we do not leak fds to any single-threaded code that could use stdio, @@ -54,7 +53,8 @@ /* Set BUF to the expansion of PROC_SELF_FD_FORMAT, using FD and FILE respectively for %d and %s. If successful, return BUF if the result fits in BUF, dynamically allocated memory otherwise. But - return NULL if /proc is not reliable. */ + return NULL if /proc is not reliable, either because the operating + system support is lacking or because memory is low. */ char * openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file) { @@ -100,7 +100,13 @@ openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file) else { size_t bufsize = PROC_SELF_FD_NAME_SIZE_BOUND (strlen (file)); - char *result = (bufsize < OPENAT_BUFFER_SIZE ? buf : xmalloc (bufsize)); + char *result = buf; + if (OPENAT_BUFFER_SIZE < bufsize) + { + result = malloc (bufsize); + if (! result) + return NULL; + } sprintf (result, PROC_SELF_FD_FORMAT, fd, file); return result; }