diff options
author | Alejandro Colomar <alx.manpages@gmail.com> | 2022-08-07 01:08:52 +0200 |
---|---|---|
committer | Alejandro Colomar <alx.manpages@gmail.com> | 2022-08-18 18:56:24 +0200 |
commit | e2aec6686a4d2cf1ddc017b50dbb39baefd2d425 (patch) | |
tree | 54829c0a1f41c2cd6d34cd92b21df3046bae1f01 /src/nxt_conf_validation.c | |
parent | d8e0768a5bae991b96328f469b8e27d8a51da9d6 (diff) | |
download | unit-e2aec6686a4d2cf1ddc017b50dbb39baefd2d425.tar.gz unit-e2aec6686a4d2cf1ddc017b50dbb39baefd2d425.tar.bz2 |
Storing abstract sockets with @ internally.
We accept both "\u0000socket-name" and "@socket-name" as abstract
unix sockets. The first one is passed to the kernel pristine,
while the second is transformed '@'->'\0'.
The commit that added support for unix sockets accepts both
variants, but we internally stored it in the same way, using
"\u0000..." for both.
We want to support abstract sockets transparently to the user, so
that if the user configures unitd with '@', if we receive a query
about the current configuration, the user should see the same
exact thing that was configured. So, this commit avoids the
transformation in the internal state file, storing user input
pristine, and we only transform the '@' for a string that will
be used internally (not user-visible).
This commit (indirectly) fixes a small bug, where we created
abstract sockets with a trailing '\0' in their name due to calling
twice nxt_sockaddr_parse() on the same string. By calling that
function only once with each copy of the string, we have fixed that
bug.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_conf_validation.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c index 3e89d775..fe6c22e5 100644 --- a/src/nxt_conf_validation.c +++ b/src/nxt_conf_validation.c @@ -1480,9 +1480,14 @@ nxt_conf_vldt_listener(nxt_conf_validation_t *vldt, nxt_str_t *name, nxt_conf_value_t *value) { nxt_int_t ret; + nxt_str_t str; nxt_sockaddr_t *sa; - sa = nxt_sockaddr_parse(vldt->pool, name); + if (nxt_slow_path(nxt_str_dup(vldt->pool, &str, name) == NULL)) { + return NXT_ERROR; + } + + sa = nxt_sockaddr_parse(vldt->pool, &str); if (nxt_slow_path(sa == NULL)) { return nxt_conf_vldt_error(vldt, "The listener address \"%V\" is invalid.", |