diff options
-rw-r--r-- | coreutils/ln.c | 4 | ||||
-rw-r--r-- | include/libbb.h | 2 | ||||
-rw-r--r-- | libbb/isdirectory.c | 15 | ||||
-rw-r--r-- | networking/httpd.c | 6 |
4 files changed, 11 insertions, 16 deletions
diff --git a/coreutils/ln.c b/coreutils/ln.c index 88a9a8f91..0eb3e6579 100644 --- a/coreutils/ln.c +++ b/coreutils/ln.c | |||
@@ -69,8 +69,8 @@ int ln_main(int argc, char **argv) | |||
69 | src = last; | 69 | src = last; |
70 | 70 | ||
71 | if (is_directory(src, | 71 | if (is_directory(src, |
72 | (opts & LN_NODEREFERENCE) ^ LN_NODEREFERENCE, | 72 | (opts & LN_NODEREFERENCE) ^ LN_NODEREFERENCE |
73 | NULL) | 73 | ) |
74 | ) { | 74 | ) { |
75 | src_name = xstrdup(*argv); | 75 | src_name = xstrdup(*argv); |
76 | src = concat_path_file(src, bb_get_last_path_component_strip(src_name)); | 76 | src = concat_path_file(src, bb_get_last_path_component_strip(src_name)); |
diff --git a/include/libbb.h b/include/libbb.h index bc9b7b06d..22d2a5b20 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -314,7 +314,7 @@ extern char *strrstr(const char *haystack, const char *needle) FAST_FUNC; | |||
314 | 314 | ||
315 | //TODO: supply a pointer to char[11] buffer (avoid statics)? | 315 | //TODO: supply a pointer to char[11] buffer (avoid statics)? |
316 | extern const char *bb_mode_string(mode_t mode) FAST_FUNC; | 316 | extern const char *bb_mode_string(mode_t mode) FAST_FUNC; |
317 | extern int is_directory(const char *name, int followLinks, struct stat *statBuf) FAST_FUNC; | 317 | extern int is_directory(const char *name, int followLinks) FAST_FUNC; |
318 | enum { /* DO NOT CHANGE THESE VALUES! cp.c, mv.c, install.c depend on them. */ | 318 | enum { /* DO NOT CHANGE THESE VALUES! cp.c, mv.c, install.c depend on them. */ |
319 | FILEUTILS_PRESERVE_STATUS = 1 << 0, /* -p */ | 319 | FILEUTILS_PRESERVE_STATUS = 1 << 0, /* -p */ |
320 | FILEUTILS_DEREFERENCE = 1 << 1, /* !-d */ | 320 | FILEUTILS_DEREFERENCE = 1 << 1, /* !-d */ |
diff --git a/libbb/isdirectory.c b/libbb/isdirectory.c index 9861be6f8..ba6c52ce8 100644 --- a/libbb/isdirectory.c +++ b/libbb/isdirectory.c | |||
@@ -15,22 +15,17 @@ | |||
15 | * Return TRUE if fileName is a directory. | 15 | * Return TRUE if fileName is a directory. |
16 | * Nonexistent files return FALSE. | 16 | * Nonexistent files return FALSE. |
17 | */ | 17 | */ |
18 | int FAST_FUNC is_directory(const char *fileName, int followLinks, struct stat *statBuf) | 18 | int FAST_FUNC is_directory(const char *fileName, int followLinks) |
19 | { | 19 | { |
20 | int status; | 20 | int status; |
21 | struct stat astatBuf; | 21 | struct stat statBuf; |
22 | |||
23 | if (statBuf == NULL) { | ||
24 | /* use auto stack buffer */ | ||
25 | statBuf = &astatBuf; | ||
26 | } | ||
27 | 22 | ||
28 | if (followLinks) | 23 | if (followLinks) |
29 | status = stat(fileName, statBuf); | 24 | status = stat(fileName, &statBuf); |
30 | else | 25 | else |
31 | status = lstat(fileName, statBuf); | 26 | status = lstat(fileName, &statBuf); |
32 | 27 | ||
33 | status = (status == 0 && S_ISDIR(statBuf->st_mode)); | 28 | status = (status == 0 && S_ISDIR(statBuf.st_mode)); |
34 | 29 | ||
35 | return status; | 30 | return status; |
36 | } | 31 | } |
diff --git a/networking/httpd.c b/networking/httpd.c index cda7cc7af..e9cd213f1 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -1302,7 +1302,7 @@ static void send_cgi_and_exit( | |||
1302 | while ((script = strchr(script + 1, '/')) != NULL) { | 1302 | while ((script = strchr(script + 1, '/')) != NULL) { |
1303 | int dir; | 1303 | int dir; |
1304 | *script = '\0'; | 1304 | *script = '\0'; |
1305 | dir = is_directory(url + 1, /*followlinks:*/ 1, NULL); | 1305 | dir = is_directory(url + 1, /*followlinks:*/ 1); |
1306 | *script = '/'; | 1306 | *script = '/'; |
1307 | if (!dir) { | 1307 | if (!dir) { |
1308 | /* not directory, found script.cgi/PATH_INFO */ | 1308 | /* not directory, found script.cgi/PATH_INFO */ |
@@ -2048,7 +2048,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
2048 | 2048 | ||
2049 | /* If URL is a directory, add '/' */ | 2049 | /* If URL is a directory, add '/' */ |
2050 | if (urlp[-1] != '/') { | 2050 | if (urlp[-1] != '/') { |
2051 | if (is_directory(urlcopy + 1, 1, NULL)) { | 2051 | if (is_directory(urlcopy + 1, /*followlinks:*/ 1)) { |
2052 | found_moved_temporarily = urlcopy; | 2052 | found_moved_temporarily = urlcopy; |
2053 | } | 2053 | } |
2054 | } | 2054 | } |
@@ -2062,7 +2062,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
2062 | while (ip_allowed && (tptr = strchr(tptr + 1, '/')) != NULL) { | 2062 | while (ip_allowed && (tptr = strchr(tptr + 1, '/')) != NULL) { |
2063 | /* have path1/path2 */ | 2063 | /* have path1/path2 */ |
2064 | *tptr = '\0'; | 2064 | *tptr = '\0'; |
2065 | if (is_directory(urlcopy + 1, 1, NULL)) { | 2065 | if (is_directory(urlcopy + 1, /*followlinks:*/ 1)) { |
2066 | /* may have subdir config */ | 2066 | /* may have subdir config */ |
2067 | parse_conf(urlcopy + 1, SUBDIR_PARSE); | 2067 | parse_conf(urlcopy + 1, SUBDIR_PARSE); |
2068 | ip_allowed = checkPermIP(); | 2068 | ip_allowed = checkPermIP(); |