diff --git a/netutils/webserver/httpd_dirlist.c b/netutils/webserver/httpd_dirlist.c index a20ab7e90..fde1190b7 100644 --- a/netutils/webserver/httpd_dirlist.c +++ b/netutils/webserver/httpd_dirlist.c @@ -193,11 +193,8 @@ ssize_t httpd_dirlist(int outfd, FAR struct httpd_fs_file *file) break; } - path = malloc(CONFIG_NAME_MAX); - ASSERT(path); - - snprintf(path, CONFIG_NAME_MAX, "%s/%s", - file->path, dent->d_name); + ret = asprintf(&path, "%s/%s", file->path, dent->d_name); + ASSERT(ret > 0 && path); /* call stat() to obtain modified time and size */