summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2023-02-12 11:25:48 +0100
committerSimon Rettberg2023-02-12 11:25:48 +0100
commitcbcbe73972db81b12b15cd9b7de5ef06a5d6d3e9 (patch)
treec953b5f6918b0775e25efe08784aaa2ff6fd7e0c /src
parent[FUSE] Fix AIOOB access (diff)
downloaddnbd3-cbcbe73972db81b12b15cd9b7de5ef06a5d6d3e9.tar.gz
dnbd3-cbcbe73972db81b12b15cd9b7de5ef06a5d6d3e9.tar.xz
dnbd3-cbcbe73972db81b12b15cd9b7de5ef06a5d6d3e9.zip
[SHARED] sock_printable: Always null-terminate
Diffstat (limited to 'src')
-rw-r--r--src/shared/sockhelper.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/shared/sockhelper.c b/src/shared/sockhelper.c
index 1970447..5096320 100644
--- a/src/shared/sockhelper.c
+++ b/src/shared/sockhelper.c
@@ -241,7 +241,10 @@ size_t sock_printable(const struct sockaddr * const addr, const socklen_t addrLe
outlen = snprintf( output, len, "[%s]:%s", host, port );
}
}
- if ( outlen <= 0 ) return 0;
+ if ( outlen <= 0 ) {
+ output[0] = '\0';
+ return 0;
+ }
return MIN( (size_t)outlen, len-1 );
}