merged partts of [192] and [194]

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.3.x@283 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.3.14
Jan Kneschke 18 years ago
parent 8a3b1f5cb0
commit 3b5fffce48

@ -295,7 +295,7 @@ esac
AC_CHECK_FUNCS([dup2 getcwd inet_ntoa inet_ntop memset mmap munmap strchr \
strdup strerror strstr strtol sendfile getopt socket \
gethostbyname poll sigtimedwait epoll_ctl getrlimit chroot \
getuid select signal\
getuid select signal pathconf\
writev sigaction sendfile64 send_file kqueue port_create localtime_r])
if test "x$ac_cv_func_sendfile" = xyes; then

@ -657,6 +657,7 @@ static int http_list_directory(server *srv, connection *con, buffer *dir) {
char datebuf[sizeof("2005-Jan-01 22:23:24")];
size_t k;
const char *content_type;
long name_max;
#ifdef HAVE_XATTR
char attrval[128];
int attrlen;
@ -667,8 +668,14 @@ static int http_list_directory(server *srv, connection *con, buffer *dir) {
i = dir->used - 1;
if (i <= 0) return -1;
#ifdef HAVE_PATHCONF
name_max = pathconf(dir->ptr, _PC_NAME_MAX);
#else
name_max = NAME_MAX;
#endif
path = malloc(i + NAME_MAX + 1);
path = malloc(i + name_max + 1);
assert(path);
strcpy(path, dir->ptr);
path_file = path + i;
@ -704,7 +711,7 @@ static int http_list_directory(server *srv, connection *con, buffer *dir) {
* so this should actually not be a buffer-overflow-risk
*/
i = strlen(dent->d_name);
if (i > NAME_MAX)
if (i > name_max)
continue;
memcpy(path_file, dent->d_name, i + 1);
if (stat(path, &st) != 0)

Loading…
Cancel
Save