diff options
author | Stefan Metzmacher <metze@samba.org> | 2021-02-05 13:13:07 +0100 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2021-02-05 14:11:31 +0100 |
commit | c3f7465f9cf453ff3bd53750db4024deaba02fb5 (patch) | |
tree | 123298d806af42b21e4965a54ac6d21620bcca58 | |
parent | fa7a9b7ab5edf3ca986979b9cdaa08deae3d9308 (diff) | |
download | socket_wrapper-c3f7465f9cf453ff3bd53750db4024deaba02fb5.tar.gz socket_wrapper-c3f7465f9cf453ff3bd53750db4024deaba02fb5.tar.xz socket_wrapper-c3f7465f9cf453ff3bd53750db4024deaba02fb5.zip |
swrap: add better logging to convert_un_in()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
-rw-r--r-- | src/socket_wrapper.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 14d0dda..5839a5c 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -1885,31 +1885,40 @@ static int convert_un_in(const struct sockaddr_un *un, struct sockaddr *in, sock if (p) p++; else p = un->sun_path; if (sscanf(p, SOCKET_FORMAT, &type, &iface, &prt) != 3) { + SWRAP_LOG(SWRAP_LOG_ERROR, "sun_path[%s] p[%s]", + un->sun_path, p); errno = EINVAL; return -1; } - SWRAP_LOG(SWRAP_LOG_TRACE, "type %c iface %u port %u", - type, iface, prt); - if (iface == 0 || iface > MAX_WRAPPED_INTERFACES) { + SWRAP_LOG(SWRAP_LOG_ERROR, "type %c iface %u port %u", + type, iface, prt); errno = EINVAL; return -1; } if (prt > 0xFFFF) { + SWRAP_LOG(SWRAP_LOG_ERROR, "type %c iface %u port %u", + type, iface, prt); errno = EINVAL; return -1; } + SWRAP_LOG(SWRAP_LOG_TRACE, "type %c iface %u port %u", + type, iface, prt); + switch(type) { case SOCKET_TYPE_CHAR_TCP: case SOCKET_TYPE_CHAR_UDP: { struct sockaddr_in *in2 = (struct sockaddr_in *)(void *)in; if ((*len) < sizeof(*in2)) { - errno = EINVAL; - return -1; + SWRAP_LOG(SWRAP_LOG_ERROR, + "V4: *len(%zu) < sizeof(*in2)=%zu", + (size_t)*len, sizeof(*in2)); + errno = EINVAL; + return -1; } memset(in2, 0, sizeof(*in2)); @@ -1926,6 +1935,10 @@ static int convert_un_in(const struct sockaddr_un *un, struct sockaddr *in, sock struct sockaddr_in6 *in2 = (struct sockaddr_in6 *)(void *)in; if ((*len) < sizeof(*in2)) { + SWRAP_LOG(SWRAP_LOG_ERROR, + "V6: *len(%zu) < sizeof(*in2)=%zu", + (size_t)*len, sizeof(*in2)); + SWRAP_LOG(SWRAP_LOG_ERROR, "LINE:%d", __LINE__); errno = EINVAL; return -1; } @@ -1941,6 +1954,8 @@ static int convert_un_in(const struct sockaddr_un *un, struct sockaddr *in, sock } #endif default: + SWRAP_LOG(SWRAP_LOG_ERROR, "type %c iface %u port %u", + type, iface, prt); errno = EINVAL; return -1; } |