One more unsafe ngx_errno usage
Sergey A. Osokin
osa at freebsd.org.ru
Wed May 13 11:14:02 UTC 2026
Hi David,
On Wed, May 13, 2026 at 03:32:32PM +0930, David Pfitzner via nginx-devel wrote:
>
> 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.
It seems to me that's related to the following line,
https://freenginx.org/hg/nginx/rev/d596a1fb8b9c#l10.28
- if (ngx_errno != NGX_ENOMEM) {
+ if (err != NGX_ENOMEM) {
Am I right?
Thank you.
--
Sergey A. Osokin
More information about the nginx-devel
mailing list