diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-10 15:43:37 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-10 15:43:37 +0000 |
commit | 99912ca733dd960f5589227fd999c86e73c8e894 (patch) | |
tree | 9df947fc08884d498cf76a02204d74b121064134 /libbb | |
parent | ff131b980d524a33d8a43cefe65e14f64a43f2da (diff) | |
download | busybox-w32-99912ca733dd960f5589227fd999c86e73c8e894.tar.gz busybox-w32-99912ca733dd960f5589227fd999c86e73c8e894.tar.bz2 busybox-w32-99912ca733dd960f5589227fd999c86e73c8e894.zip |
audit small applets and mark some of them as NOFORK.
Put big scary warnings in relevant places.
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/copyfd.c | 11 | ||||
-rw-r--r-- | libbb/fflush_stdout_and_exit.c | 4 | ||||
-rw-r--r-- | libbb/make_directory.c | 5 | ||||
-rw-r--r-- | libbb/parse_mode.c | 2 | ||||
-rw-r--r-- | libbb/remove_file.c | 2 |
5 files changed, 14 insertions, 10 deletions
diff --git a/libbb/copyfd.c b/libbb/copyfd.c index 805b80187..e0596d5f6 100644 --- a/libbb/copyfd.c +++ b/libbb/copyfd.c | |||
@@ -7,19 +7,15 @@ | |||
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <errno.h> | ||
11 | #include <stdlib.h> | ||
12 | #include <string.h> | ||
13 | #include <unistd.h> | ||
14 | |||
15 | #include "libbb.h" | 10 | #include "libbb.h" |
16 | 11 | ||
17 | |||
18 | #if BUFSIZ < 4096 | 12 | #if BUFSIZ < 4096 |
19 | #undef BUFSIZ | 13 | #undef BUFSIZ |
20 | #define BUFSIZ 4096 | 14 | #define BUFSIZ 4096 |
21 | #endif | 15 | #endif |
22 | 16 | ||
17 | /* Used by NOFORK applets (e.g. cat) - must be very careful | ||
18 | * when calling xfuncs, allocating memory, with signals, termios, etc... */ | ||
23 | 19 | ||
24 | static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size) | 20 | static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size) |
25 | { | 21 | { |
@@ -27,7 +23,8 @@ static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size) | |||
27 | off_t total = 0; | 23 | off_t total = 0; |
28 | RESERVE_CONFIG_BUFFER(buffer, BUFSIZ); | 24 | RESERVE_CONFIG_BUFFER(buffer, BUFSIZ); |
29 | 25 | ||
30 | if (src_fd < 0) goto out; | 26 | if (src_fd < 0) |
27 | goto out; | ||
31 | 28 | ||
32 | if (!size) { | 29 | if (!size) { |
33 | size = BUFSIZ; | 30 | size = BUFSIZ; |
diff --git a/libbb/fflush_stdout_and_exit.c b/libbb/fflush_stdout_and_exit.c index 6f44770c6..ae68222b4 100644 --- a/libbb/fflush_stdout_and_exit.c +++ b/libbb/fflush_stdout_and_exit.c | |||
@@ -13,6 +13,10 @@ | |||
13 | 13 | ||
14 | #include "libbb.h" | 14 | #include "libbb.h" |
15 | 15 | ||
16 | // TODO: make it safe to call from NOFORK applets | ||
17 | // Currently, it can exit(0). Even if it is made to do longjmp trick | ||
18 | // (see sleep_and_die internals), zero cannot be passed thru this way! | ||
19 | |||
16 | void fflush_stdout_and_exit(int retval) | 20 | void fflush_stdout_and_exit(int retval) |
17 | { | 21 | { |
18 | if (fflush(stdout)) | 22 | if (fflush(stdout)) |
diff --git a/libbb/make_directory.c b/libbb/make_directory.c index fbec4e20e..d540ad133 100644 --- a/libbb/make_directory.c +++ b/libbb/make_directory.c | |||
@@ -22,11 +22,10 @@ | |||
22 | * val. Otherwise, pass -1 to get default permissions. | 22 | * val. Otherwise, pass -1 to get default permissions. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <errno.h> | ||
26 | #include <unistd.h> | ||
27 | #include <sys/stat.h> | ||
28 | #include "libbb.h" | 25 | #include "libbb.h" |
29 | 26 | ||
27 | /* This function is used from NOFORK applets. It must not allocate anything */ | ||
28 | |||
30 | int bb_make_directory (char *path, long mode, int flags) | 29 | int bb_make_directory (char *path, long mode, int flags) |
31 | { | 30 | { |
32 | mode_t mask; | 31 | mode_t mask; |
diff --git a/libbb/parse_mode.c b/libbb/parse_mode.c index 3ab4eb6fc..a31bd4bfd 100644 --- a/libbb/parse_mode.c +++ b/libbb/parse_mode.c | |||
@@ -11,6 +11,8 @@ | |||
11 | 11 | ||
12 | #include "libbb.h" | 12 | #include "libbb.h" |
13 | 13 | ||
14 | /* This function is used from NOFORK applets. It must not allocate anything */ | ||
15 | |||
14 | #define FILEMODEBITS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) | 16 | #define FILEMODEBITS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) |
15 | 17 | ||
16 | int bb_parse_mode(const char *s, mode_t *current_mode) | 18 | int bb_parse_mode(const char *s, mode_t *current_mode) |
diff --git a/libbb/remove_file.c b/libbb/remove_file.c index 3aaaef8c7..3edc91dae 100644 --- a/libbb/remove_file.c +++ b/libbb/remove_file.c | |||
@@ -9,6 +9,8 @@ | |||
9 | 9 | ||
10 | #include "libbb.h" | 10 | #include "libbb.h" |
11 | 11 | ||
12 | /* Used from NOFORK applets. Must not allocate anything */ | ||
13 | |||
12 | int remove_file(const char *path, int flags) | 14 | int remove_file(const char *path, int flags) |
13 | { | 15 | { |
14 | struct stat path_stat; | 16 | struct stat path_stat; |