About the UNIX socket path length check

Peter Wu peter at lekensteyn.nl
Thu Oct 9 16:02:16 UTC 2014


Hi,

In src/core/ngx_inet.c we have this code:

    if (len > sizeof(saun->sun_path)) {
        u->err = "too long path in the unix domain socket";
        return NGX_ERROR;
    }

But a NUL-terminated string requires one byte more. Is it allowed to
omit the NUL byte when the string would not fit otherwise? If not,
this should be changed to:

    if (len >= sizeof(saun->sun_path)) {
        u->err = "too long path in the unix domain socket";
        return NGX_ERROR;
    }

-- 
Kind regards,
Peter
https://lekensteyn.nl



More information about the nginx-devel mailing list