Skip to content

Commit d0d48ca

Browse files
committed
http server: sprintf is considered deprecated
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.
1 parent 87bc256 commit d0d48ca

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/supplemental/http/http_server.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,8 @@ http_handle_dir(nni_aio *aio)
15711571

15721572
rv = 0;
15731573
if (nni_file_is_dir(pn)) {
1574-
sprintf(dst, "%s%s", NNG_PLATFORM_DIR_SEP, "index.html");
1574+
snprintf(dst, pnsz - strlen(pn), "%s%s", NNG_PLATFORM_DIR_SEP,
1575+
"index.html");
15751576
if (!nni_file_is_file(pn)) {
15761577
pn[strlen(pn) - 1] = '\0'; // index.html -> index.htm
15771578
if (!nni_file_is_file(pn)) {

0 commit comments

Comments
 (0)