mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-25 07:49:18 +00:00
realpath(3): Minor style issues.
Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D46695
This commit is contained in:
parent
e47161e5f1
commit
abed32f91d
@ -33,10 +33,10 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <ssp/ssp.h>
|
||||
#include "un-namespace.h"
|
||||
#include "libc_private.h"
|
||||
@ -146,13 +146,14 @@ realpath1(const char *path, char *resolved)
|
||||
return (NULL);
|
||||
}
|
||||
slen = readlink(resolved, symlink, sizeof(symlink));
|
||||
if (slen <= 0 || slen >= (ssize_t)sizeof(symlink)) {
|
||||
if (slen < 0)
|
||||
; /* keep errno from readlink(2) call */
|
||||
else if (slen == 0)
|
||||
errno = ENOENT;
|
||||
else
|
||||
errno = ENAMETOOLONG;
|
||||
if (slen < 0)
|
||||
return (NULL);
|
||||
if (slen == 0) {
|
||||
errno = ENOENT;
|
||||
return (NULL);
|
||||
}
|
||||
if ((size_t)slen >= sizeof(symlink)) {
|
||||
errno = ENAMETOOLONG;
|
||||
return (NULL);
|
||||
}
|
||||
symlink[slen] = '\0';
|
||||
@ -173,7 +174,7 @@ realpath1(const char *path, char *resolved)
|
||||
*/
|
||||
if (p != NULL) {
|
||||
if (symlink[slen - 1] != '/') {
|
||||
if (slen + 1 >= (ssize_t)sizeof(symlink)) {
|
||||
if ((size_t)slen + 1 >= sizeof(symlink)) {
|
||||
errno = ENAMETOOLONG;
|
||||
return (NULL);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user