nginx/src
Andrew Clayton b0a4d0fb82
Some checks failed
buildbot / buildbot (push) Has been cancelled
Avoid undefined behaviour in ngx_pstrdup()
In the third call to ngx_pstrdup() for setting cycle->conf_param.data in
ngx_init_cycle() we would pass in a nulled ngx_str_t in the case there
was no -g command line option passed to nginx.

This would result in a

  memcpy(dst, NULL, 0)

which up to and including C23 is Undefined Behaviour.

Currently Clang and GCC (in this particular case) just treat this as a
no-op, so things just happen to work.

However some undefined behaviour sanitizers will throw an error when
this is hit, e.g. Clang and the zig compiler and it's probably best not
to rely on this behaviour.

It's worth noting that the next C standard will make this (and other
NULL related operations) defined behaviour.

Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>
Closes: https://github.com/nginx/nginx/issues/1079
2026-04-20 19:56:40 +01:00
..
core Avoid undefined behaviour in ngx_pstrdup() 2026-04-20 19:56:40 +01:00
event SSL: logging level of "record layer failure" errors 2026-04-16 18:39:23 +04:00
http HTTP/3: optimize encoder stream memory usage 2026-04-16 19:47:46 +04:00
mail Mail: fixed clearing s->passwd in auth http requests. 2026-03-24 18:46:36 +04:00
misc Cpp test: added stream. 2020-10-13 07:44:09 +03:00
os Win32: fixed C4319 warning with MSVC 2022 x86. 2025-12-24 11:41:43 -07:00
stream Stream: support ALPN for proxy_ssl upstream. 2026-04-17 14:16:31 -07:00