One more unsafe ngx_errno usage

David Pfitzner dpfitzner at netflix.com
Wed May 13 06:02:32 UTC 2026


Hi,

A while ago there was this commit:
https://freenginx.org/hg/nginx/rev/d596a1fb8b9c
"Cleaned up unsafe ngx_errno and ngx_socket_errno usage."

I just noticed that one part of the above fix was incomplete. In
src/os/unix/ngx_freebsd_init.c (tip) starting at line 125 we have:

    if (sysctlbyname("kern.osrelease",
                     ngx_freebsd_kern_osrelease, &size, NULL, 0) == -1) {
        err = ngx_errno;

        ngx_log_error(NGX_LOG_ALERT, log, err,
                      "sysctlbyname(kern.osrelease) failed");

        if (ngx_errno != NGX_ENOMEM) {
            return NGX_ERROR;
        }

In the 'if' condition at the end, I think 'ngx_errno' should instead be
'err' (similar to the code block just previous). Sorry, I didn't create a
patch, but the fix is simple.

Regards,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://freenginx.org/pipermail/nginx-devel/attachments/20260513/3f2ca12f/attachment.htm>


More information about the nginx-devel mailing list