Skip to content

Commit

Permalink
http server: sprintf is considered deprecated
Browse files Browse the repository at this point in the history
Because it is typically associated with insecure code, use of sprintf
is discouraged.  Note that our usage was actually quite careful and
not insecure, but its mere presence raises concern especially by parties
who are unwilling or unable to assess the actual code for correctness.

A better choice here would be strlcat, but strlcat is not universally
available.
  • Loading branch information
gdamore committed Nov 30, 2024
1 parent e4c8ae2 commit 8040aeb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/supplemental/http/http_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,8 @@ http_handle_dir(nni_aio *aio)

rv = 0;
if (nni_file_is_dir(pn)) {
sprintf(dst, "%s%s", NNG_PLATFORM_DIR_SEP, "index.html");
snprintf(dst, pnsz - strlen(pn), "%s%s", NNG_PLATFORM_DIR_SEP,
"index.html");
if (!nni_file_is_file(pn)) {
pn[strlen(pn) - 1] = '\0'; // index.html -> index.htm
if (!nni_file_is_file(pn)) {
Expand Down

0 comments on commit 8040aeb

Please sign in to comment.