nginx/src/core
Andrew Clayton b0a4d0fb82 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
..
nginx.c Core: fixed environment variables on exit. 2023-07-19 05:09:23 +03:00
nginx.h Version bump 2026-04-13 14:20:23 +01:00
ngx_array.c
ngx_array.h
ngx_bpf.c Core: fixed build with BPF on non-64bit platforms (ticket #2152). 2021-03-23 10:58:18 +03:00
ngx_bpf.h Core: added interface to linux bpf() system call. 2020-12-15 15:23:07 +03:00
ngx_buf.c Changed ngx_chain_update_chains() to test tag first (ticket #2248). 2021-10-30 02:39:19 +03:00
ngx_buf.h Simplified sendfile(SF_NODISKIO) usage. 2021-12-27 19:48:33 +03:00
ngx_conf_file.c Style. 2022-12-16 01:15:15 +04:00
ngx_conf_file.h Core: enabled "include" in any context (ticket #1615). 2019-04-09 11:40:20 +03:00
ngx_config.h Core: improved NGX_ALIGNMENT detection on some x86_64 platforms. 2025-04-18 12:57:26 -07:00
ngx_connection.c The "multipath" parameter of the "listen" directive. 2026-03-19 01:13:51 +04:00
ngx_connection.h The "multipath" parameter of the "listen" directive. 2026-03-19 01:13:51 +04:00
ngx_core.h Upstream: fixed --with-compat build without SSL, broken by 454ad0e. 2025-01-23 10:50:13 -08:00
ngx_cpuinfo.c
ngx_crc.h
ngx_crc32.c
ngx_crc32.h
ngx_crypt.c An internal SHA1 implementation. 2016-06-09 16:55:38 +03:00
ngx_crypt.h
ngx_cycle.c Avoid undefined behaviour in ngx_pstrdup() 2026-04-20 19:56:40 +01:00
ngx_cycle.h Core: "-e" command line option. 2020-11-19 16:59:00 +00:00
ngx_file.c Win32: removed NGX_DIR_MASK concept. 2018-12-24 21:07:05 +03:00
ngx_file.h Modules compatibility: compatibility with NGX_HAVE_FILE_AIO. 2016-10-10 18:44:17 +03:00
ngx_hash.c Core: removed unnecessary restriction in hash initialization. 2021-08-19 20:51:27 +03:00
ngx_hash.h FastCGI: combining headers with identical names (ticket #1724). 2022-05-30 21:25:27 +03:00
ngx_inet.c Realip: allowed square brackets with portless IPv6 address. 2024-11-26 18:27:07 +04:00
ngx_inet.h Multiple addresses in "listen". 2019-03-15 15:45:56 +03:00
ngx_list.c
ngx_list.h
ngx_log.c Core: "-e" command line option. 2020-11-19 16:59:00 +00:00
ngx_log.h Added COMPAT section to ngx_log_t. 2026-03-23 09:38:11 -07:00
ngx_md5.c Internal md5 and sha1 implementations are now always used. 2016-06-30 18:57:39 +03:00
ngx_md5.h Internal md5 and sha1 implementations are now always used. 2016-06-30 18:57:39 +03:00
ngx_module.c Fixed compilation with -Wmissing-prototypes. 2016-03-14 19:23:23 +03:00
ngx_module.h Modules compatibility: added QUIC to signature (ticket #2539). 2023-09-13 17:48:15 +04:00
ngx_murmurhash.c Added missing "fall through" comments (ticket #1259). 2017-04-27 16:57:18 +03:00
ngx_murmurhash.h
ngx_open_file_cache.c Fixed logging in close error handling. 2016-03-31 02:33:50 +03:00
ngx_open_file_cache.h
ngx_output_chain.c Output chain: clear the last_buf flag unless inherited. 2026-01-29 14:52:41 +04:00
ngx_palloc.c Core: introduced the NGX_DEBUG_PALLOC macro. 2016-03-23 17:44:04 +03:00
ngx_palloc.h Core: removed extra ngx_alloc() and ngx_calloc() prototypes. 2017-04-18 13:01:19 +03:00
ngx_parse.c Fixed ngx_parse_size() / ngx_parse_offset() with 0-length strings. 2017-02-17 17:01:27 +03:00
ngx_parse.h
ngx_parse_time.c Style. 2017-09-13 15:51:52 +03:00
ngx_parse_time.h
ngx_proxy_protocol.c Fixed PROXY protocol to use ngx_memcpy()/ngx_memcmp(). 2022-11-08 12:48:21 +03:00
ngx_proxy_protocol.h Increased maximum read PROXY protocol header size. 2022-11-02 13:46:16 +04:00
ngx_queue.c Core: changed ngx_queue_sort() to use merge sort. 2023-10-18 04:30:11 +03:00
ngx_queue.h Core: changed ngx_queue_sort() to use merge sort. 2023-10-18 04:30:11 +03:00
ngx_radix_tree.c
ngx_radix_tree.h
ngx_rbtree.c Core: removed dead code in ngx_rbtree_delete(). 2019-09-30 16:39:20 +03:00
ngx_rbtree.h Core: added the ngx_rbtree_data() macro. 2021-06-21 09:42:43 +03:00
ngx_regex.c Core: fixed memory leak on configuration reload with PCRE2. 2023-10-17 02:39:38 +03:00
ngx_regex.h Core: added NGX_REGEX_MULTILINE for 3rd party modules. 2021-12-25 01:07:18 +03:00
ngx_resolver.c Resolver: fixed off-by-one read in ngx_resolver_copy(). 2026-02-23 22:12:32 +04:00
ngx_resolver.h The "ipv4=" parameter of the "resolver" directive. 2022-07-12 21:44:02 +04:00
ngx_rwlock.c Core: simplify reader lock release. 2022-01-19 17:37:34 -08:00
ngx_rwlock.h Introduced ngx_rwlock_downgrade(). 2017-06-16 18:15:58 +03:00
ngx_sha1.c Internal md5 and sha1 implementations are now always used. 2016-06-30 18:57:39 +03:00
ngx_sha1.h Internal md5 and sha1 implementations are now always used. 2016-06-30 18:57:39 +03:00
ngx_shmtx.c
ngx_shmtx.h
ngx_slab.c Slab: removed redundant page calculation (ticket #1721). 2019-02-12 21:51:15 +03:00
ngx_slab.h Slab: fixed initialization on win32. 2017-08-08 15:16:01 +03:00
ngx_spinlock.c
ngx_string.c Mail: xtext encoding (RFC 3461) in XCLIENT LOGIN. 2025-09-26 17:04:20 +04:00
ngx_string.h Mail: xtext encoding (RFC 3461) in XCLIENT LOGIN. 2025-09-26 17:04:20 +04:00
ngx_syslog.c Syslog: introduced error log handler. 2023-03-10 07:43:50 +03:00
ngx_syslog.h Syslog: introduced error log handler. 2023-03-10 07:43:50 +03:00
ngx_thread_pool.c Use NULL instead of 0 for null pointer constant. 2025-06-21 10:36:45 +04:00
ngx_thread_pool.h
ngx_times.c Removed CLOCK_MONOTONIC_FAST support. 2026-04-03 11:57:21 -07:00
ngx_times.h Core: fixed comment about ngx_current_msec after 81fae70d6cb8. 2018-05-29 16:15:19 +03:00