mirror of
https://github.com/fluencelabs/musl
synced 2025-04-25 07:12:15 +00:00
guard against hard links to non-ordinary-files when reading tcb shadow
This commit is contained in:
parent
ca1aa5bae9
commit
976f42d1f1
@ -1,5 +1,6 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include "pwf.h"
|
#include "pwf.h"
|
||||||
|
|
||||||
/* This implementation support Openwall-style TCB passwords in place of
|
/* 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);
|
fd = open(path, O_RDONLY|O_NOFOLLOW|O_NONBLOCK);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
f = fdopen(fd, "rb");
|
struct stat st = { 0 };
|
||||||
if (!f) {
|
errno = EINVAL;
|
||||||
|
if (fstat(fd, &st) || !S_ISREG(st.st_mode) || !(f = fdopen(fd, "rb"))) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user