summaryrefslogtreecommitdiff
path: root/src/listenwk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/listenwk.c')
-rw-r--r--src/listenwk.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/listenwk.c b/src/listenwk.c
index 4050989..37735b7 100644
--- a/src/listenwk.c
+++ b/src/listenwk.c
@@ -58,8 +58,11 @@ IceListenForWellKnownConnections (
*listenObjsRet = NULL;
*countRet = 0;
- strncpy (errorStringRet,
- "Cannot establish any listening sockets", errorLength);
+ if (errorStringRet && errorLength > 0) {
+ strncpy (errorStringRet,
+ "Cannot establish any listening sockets", errorLength);
+ errorStringRet[errorLength - 1] = '\0';
+ }
return (0);
}
@@ -91,8 +94,11 @@ IceListenForWellKnownConnections (
{
*listenObjsRet = NULL;
- strncpy (errorStringRet,
- "Cannot establish any listening sockets", errorLength);
+ if (errorStringRet && errorLength > 0) {
+ strncpy (errorStringRet,
+ "Cannot establish any listening sockets", errorLength);
+ errorStringRet[errorLength - 1] = '\0';
+ }
status = 0;
}
@@ -102,7 +108,10 @@ IceListenForWellKnownConnections (
if (*listenObjsRet == NULL)
{
- strncpy (errorStringRet, "Malloc failed", errorLength);
+ if (errorStringRet && errorLength > 0) {
+ strncpy (errorStringRet, "Malloc failed", errorLength);
+ errorStringRet[errorLength - 1] = '\0';
+ }
status = 0;
}
@@ -114,7 +123,10 @@ IceListenForWellKnownConnections (
if ((*listenObjsRet)[i] == NULL)
{
- strncpy (errorStringRet, "Malloc failed", errorLength);
+ if (errorStringRet && errorLength > 0) {
+ strncpy (errorStringRet, "Malloc failed", errorLength);
+ errorStringRet[errorLength - 1] = '\0';
+ }
for (j = 0; j < i; j++)
free ((*listenObjsRet)[j]);