mirror of
git://git.musl-libc.org/musl
synced 2025-03-06 20:48:29 +01:00
guard against hard links to non-ordinary-files when reading tcb shadow
This commit is contained in:
parent
ca1aa5bae9
commit
976f42d1f1
1 changed files with 4 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include "pwf.h"
|
||||
|
||||
/* This implementation support Openwall-style TCB passwords in place of
|
||||
|
@ -34,8 +35,9 @@ int getspnam_r(const char *name, struct spwd *sp, char *buf, size_t size, struct
|
|||
|
||||
fd = open(path, O_RDONLY|O_NOFOLLOW|O_NONBLOCK);
|
||||
if (fd >= 0) {
|
||||
f = fdopen(fd, "rb");
|
||||
if (!f) {
|
||||
struct stat st = { 0 };
|
||||
errno = EINVAL;
|
||||
if (fstat(fd, &st) || !S_ISREG(st.st_mode) || !(f = fdopen(fd, "rb"))) {
|
||||
close(fd);
|
||||
return errno;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue