diff options
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/dump.c | 4 | ||||
-rw-r--r-- | libbb/update_passwd.c | 2 | ||||
-rw-r--r-- | libbb/xfuncs_printf.c | 10 |
3 files changed, 12 insertions, 4 deletions
diff --git a/libbb/dump.c b/libbb/dump.c index a739ff61e..4db3f06f0 100644 --- a/libbb/dump.c +++ b/libbb/dump.c | |||
@@ -323,9 +323,7 @@ static void do_skip(priv_dumper_t *dumper, const char *fname, int statok) | |||
323 | struct stat sbuf; | 323 | struct stat sbuf; |
324 | 324 | ||
325 | if (statok) { | 325 | if (statok) { |
326 | if (fstat(STDIN_FILENO, &sbuf)) { | 326 | xfstat(STDIN_FILENO, &sbuf, fname); |
327 | bb_simple_perror_msg_and_die(fname); | ||
328 | } | ||
329 | if (!(S_ISCHR(sbuf.st_mode) || S_ISBLK(sbuf.st_mode) || S_ISFIFO(sbuf.st_mode)) | 327 | if (!(S_ISCHR(sbuf.st_mode) || S_ISBLK(sbuf.st_mode) || S_ISFIFO(sbuf.st_mode)) |
330 | && dumper->pub.dump_skip >= sbuf.st_size | 328 | && dumper->pub.dump_skip >= sbuf.st_size |
331 | ) { | 329 | ) { |
diff --git a/libbb/update_passwd.c b/libbb/update_passwd.c index e050dfc0e..a2be0f155 100644 --- a/libbb/update_passwd.c +++ b/libbb/update_passwd.c | |||
@@ -133,7 +133,7 @@ int FAST_FUNC update_passwd(const char *filename, | |||
133 | goto close_old_fp; | 133 | goto close_old_fp; |
134 | 134 | ||
135 | created: | 135 | created: |
136 | if (!fstat(old_fd, &sb)) { | 136 | if (fstat(old_fd, &sb) == 0) { |
137 | fchmod(new_fd, sb.st_mode & 0777); /* ignore errors */ | 137 | fchmod(new_fd, sb.st_mode & 0777); /* ignore errors */ |
138 | fchown(new_fd, sb.st_uid, sb.st_gid); | 138 | fchown(new_fd, sb.st_uid, sb.st_gid); |
139 | } | 139 | } |
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index b99f906df..c6db38d33 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
@@ -436,6 +436,16 @@ void FAST_FUNC xstat(const char *name, struct stat *stat_buf) | |||
436 | bb_perror_msg_and_die("can't stat '%s'", name); | 436 | bb_perror_msg_and_die("can't stat '%s'", name); |
437 | } | 437 | } |
438 | 438 | ||
439 | void FAST_FUNC xfstat(int fd, struct stat *stat_buf, const char *errmsg) | ||
440 | { | ||
441 | /* errmsg is usually a file name, but not always: | ||
442 | * xfstat may be called in a spot where file name is no longer | ||
443 | * available, and caller may give e.g. "can't stat input file" string. | ||
444 | */ | ||
445 | if (fstat(fd, stat_buf)) | ||
446 | bb_simple_perror_msg_and_die(errmsg); | ||
447 | } | ||
448 | |||
439 | // selinux_or_die() - die if SELinux is disabled. | 449 | // selinux_or_die() - die if SELinux is disabled. |
440 | void FAST_FUNC selinux_or_die(void) | 450 | void FAST_FUNC selinux_or_die(void) |
441 | { | 451 | { |