mirror of
https://github.com/sheumann/hush.git
synced 2024-07-06 04:28:58 +00:00
- commentary fixes
- use common exit sequence for failure path: text data bss dec hex filename 308 0 0 308 134 libbb/xreadlink.o.pgf 296 0 0 296 128 libbb/xreadlink.o
This commit is contained in:
parent
599bbfbd9b
commit
9bd8d0c23e
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE: This function returns a malloced char* that you will have to free
|
* NOTE: This function returns a malloced char* that you will have to free
|
||||||
* yourself. You have been warned.
|
* yourself.
|
||||||
*/
|
*/
|
||||||
char *xmalloc_readlink(const char *path)
|
char *xmalloc_readlink(const char *path)
|
||||||
{
|
{
|
||||||
@ -33,14 +33,14 @@ char *xmalloc_readlink(const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* this routine is not the same as realpath(), which
|
* This routine is not the same as realpath(), which
|
||||||
* canonicalizes the given path completely. this routine only
|
* canonicalizes the given path completely. This routine only
|
||||||
* follows trailing symlinks until a real file is reached, and
|
* follows trailing symlinks until a real file is reached and
|
||||||
* returns its name. if the path ends in a dangling link, or if
|
* returns its name. If the path ends in a dangling link or if
|
||||||
* the target doesn't exist, the path is returned in any case.
|
* the target doesn't exist, the path is returned in any case.
|
||||||
* intermediate symlinks in the path are not expanded -- only
|
* Intermediate symlinks in the path are not expanded -- only
|
||||||
* those at the tail.
|
* those at the tail.
|
||||||
* a malloced char* is returned, which must be freed by the caller.
|
* A malloced char* is returned, which must be freed by the caller.
|
||||||
*/
|
*/
|
||||||
char *xmalloc_follow_symlinks(const char *path)
|
char *xmalloc_follow_symlinks(const char *path)
|
||||||
{
|
{
|
||||||
@ -60,12 +60,12 @@ char *xmalloc_follow_symlinks(const char *path)
|
|||||||
/* not a symlink, or doesn't exist */
|
/* not a symlink, or doesn't exist */
|
||||||
if (errno == EINVAL || errno == ENOENT)
|
if (errno == EINVAL || errno == ENOENT)
|
||||||
return buf;
|
return buf;
|
||||||
free(buf);
|
goto free_buf_ret_null;
|
||||||
return NULL;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!--looping) {
|
if (!--looping) {
|
||||||
free(linkpath);
|
free(linkpath);
|
||||||
|
free_buf_ret_null:
|
||||||
free(buf);
|
free(buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user