<div dir="ltr"><div dir="ltr"><br></div><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, May 13, 2026 at 10:51 PM Maxim Dounin <<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello!<br>
<br>
On Wed, May 13, 2026 at 03:32:32PM +0930, David Pfitzner via nginx-devel wrote:<br>
<br>
> A while ago there was this commit:<br>
> <a href="https://freenginx.org/hg/nginx/rev/d596a1fb8b9c" rel="noreferrer" target="_blank">https://freenginx.org/hg/nginx/rev/d596a1fb8b9c</a><br>
> "Cleaned up unsafe ngx_errno and ngx_socket_errno usage."<br>
> <br>
> I just noticed that one part of the above fix was incomplete. In<br>
> src/os/unix/ngx_freebsd_init.c (tip) starting at line 125 we have:<br>
> <br>
> if (sysctlbyname("kern.osrelease",<br>
> ngx_freebsd_kern_osrelease, &size, NULL, 0) == -1) {<br>
> err = ngx_errno;<br>
> <br>
> ngx_log_error(NGX_LOG_ALERT, log, err,<br>
> "sysctlbyname(kern.osrelease) failed");<br>
> <br>
> if (ngx_errno != NGX_ENOMEM) {<br>
> return NGX_ERROR;<br>
> }<br>
> <br>
> In the 'if' condition at the end, I think 'ngx_errno' should instead be<br>
> 'err' (similar to the code block just previous). Sorry, I didn't create a<br>
> patch, but the fix is simple.<br>
<br>
Sure, thanks for catching this.<br>
Just in case, the patch is below:<br>
<br>
# HG changeset patch<br>
# User Maxim Dounin <<a href="mailto:mdounin@mdounin.ru" target="_blank">mdounin@mdounin.ru</a>><br>
# Date 1778678442 -10800<br>
# Wed May 13 16:20:42 2026 +0300<br>
# Node ID 5fec4281a4931de7888a7994ff1bd7f6d7254fb7<br>
# Parent 207b425c3dba591ba7dcd9e5533ae20bb0e0caed<br>
Fixed unsafe ngx_errno usage, missed in 9457:d596a1fb8b9c.<br>
<br>
Reported by David Pfitzner.<br>
<br>
diff --git a/src/os/unix/ngx_freebsd_init.c <br>
b/src/os/unix/ngx_freebsd_init.c<br>
--- a/src/os/unix/ngx_freebsd_init.c<br>
+++ b/src/os/unix/ngx_freebsd_init.c<br>
@@ -129,7 +129,7 @@ ngx_os_specific_init(ngx_log_t *log)<br>
ngx_log_error(NGX_LOG_ALERT, log, err,<br>
"sysctlbyname(kern.osrelease) failed");<br>
<br>
- if (ngx_errno != NGX_ENOMEM) {<br>
+ if (err != NGX_ENOMEM) {<br>
return NGX_ERROR;<br>
}<br>
<br>
<br><br></blockquote>Yes, that patch looks good, thanks! </div><div class="gmail_quote gmail_quote_container"><br class="gmail-Apple-interchange-newline"><div>-- David </div></div></div>