casaroli opened a new pull request, #4029:
URL: https://github.com/apache/nuttx-apps/pull/4029

   depends-on: apache/nuttx/pull/21729
   
   ## Summary
   
   This PR fixes four bugs of netutils/thttpd. Each fix is in its own commit.
   
   1. `ls()` gives `task_create()` an argument list with one entry and no NULL 
at the end. `task_create()` reads past the array to count and copy the 
arguments. On qemu-armv8a the server task crashed with a data abort at the 
first request for a directory index (`CONFIG_THTTPD_GENERATE_INDICES`). The 
list now ends with NULL, as in `cgi()`.
   
   2. Debug messages in `thttpd_alloc.c` and `thttpd_cgi.c` print `size_t` and 
`ssize_t` values with `%d` (11 places). On a 64-bit target these types are 
wider than `int`, so the format check fails and `-Werror` stops the build. The 
check also runs when the debug output is off (`_none()` keeps the arguments in 
an `if (0)` call), so a plain thttpd build on a 64-bit target does not compile. 
The messages now use `%zu` and `%zd`.
   
   3. With `CONFIG_THTTPD_USE_URLPATTERN`, `check_referer()` puts the result of 
`really_check_referer()` in a variable that it does not use. It then tests and 
returns `r`, which it does not set, so the result of the referer check is 
random. The compiler stops a `-Werror` build with `variable 'child' set but not 
used`. The result now goes into `r`.
   
   4. With `CONFIG_THTTPD_MEMDEBUG` and `CONFIG_THTTPD_GENERATE_INDICES`, 
`ls_child()` gives `RENEW()` the old size in `oldmax`, which does not exist, so 
the build fails (`'oldmax' undeclared`). `RENEW()` uses the old size only for 
the memory debug statistics. It now gets the old value of `maxnames`, which is 
doubled after the two calls.
   
   The first commit only adds the blank lines after declarations that nxstyle 
wants in `thttpd_alloc.c`, because the CI check runs nxstyle on each changed 
file as a whole.
   
   ## Impact
   
   Only netutils/thttpd. Fixes 2 and 4 change only the text of debug messages 
and the memory debug statistics. Fix 3 makes the referer check work when 
`CONFIG_THTTPD_USE_URLPATTERN` is set.
   
   ## Testing
   
   nuttx master e8b03dade4c, Make, `EXTRAFLAGS="-Wno-cpp -Werror"`. "thttpd" is 
`FS_BINFS`, `NETUTILS_THTTPD`, `THTTPD_BINFS`. "all options" adds 
`THTTPD_USE_AUTH_FILE`, `THTTPD_CGIDUMP`, `THTTPD_USE_URLPATTERN`, 
`THTTPD_USE_TILDE_MAP1`, `THTTPD_GENERATE_INDICES`, `DEBUG_FEATURES`, 
`DEBUG_NET` (error, warning, info) and `THTTPD_MEMDEBUG`.
   
   | Configuration | apps master 7f9ae9513 | this PR |
   |---|---|---|
   | `qemu-armv8a:netnsh` + thttpd (64-bit) | 7 errors, for example 
`thttpd_alloc.c:174:12: error: format '%d' expects argument of type 'int', but 
argument 3 has type 'size_t' {aka 'long unsigned int'}` and 6 in `thttpd_cgi.c` 
| builds, no warnings |
   | `qemu-armv8a:netnsh` + all options (64-bit) | `libhttpd.c:1691:46: error: 
'oldmax' undeclared`, `libhttpd.c:1969:7: error: variable 'child' set but not 
used` | builds, no warnings |
   | `lincoln60:thttpd-binfs` + thttpd (32-bit, GNU EABI toolchain 13.2) | 
builds, no warnings | builds, no warnings |
   | `lincoln60:thttpd-binfs` + all options (32-bit) | the same 2 errors 
(`oldmax`, `child`) | builds, no warnings |
   
   GCC does not report the format errors of the four `CONFIG_THTTPD_MEMDEBUG` 
messages: with debug output on, the call comes from a macro of a header that is 
given with `-isystem`. These four are fixed by reading the code.
   
   Not run: a request for a directory index. In the test of 
apache/nuttx-apps#3961, the index task still crashed after fix 1, in a 
corrupted semaphore; that needs its own fix.
   
   `tools/checkpatch.sh -c -u -m -g` passes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • [PR] netutils/thttpd: Fix the... casaroli (via GitHub) via commits

Reply via email to