projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ca1aa5b
)
guard against hard links to non-ordinary-files when reading tcb shadow
author
Rich Felker
<dalias@aerifal.cx>
Tue, 15 Feb 2011 02:15:07 +0000
(21:15 -0500)
committer
Rich Felker
<dalias@aerifal.cx>
Tue, 15 Feb 2011 02:15:07 +0000
(21:15 -0500)
src/passwd/getspnam_r.c
patch
|
blob
|
history
diff --git
a/src/passwd/getspnam_r.c
b/src/passwd/getspnam_r.c
index 1dd39ce01d973e5f8268cf6775fab909ce12fb49..d21ca810eb68c481c37b9b98f134d02cf70a41a5 100644
(file)
--- a/
src/passwd/getspnam_r.c
+++ b/
src/passwd/getspnam_r.c
@@
-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;
}