summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2018-07-10 15:32:28 +0000
committerMatthieu Herrb <matthieu@herrb.eu>2020-07-14 15:52:40 +0200
commit4e46d519b146304c23bcd37d9720bacd18d46e80 (patch)
tree0c84412daac365af3dfa6aed8b77d99cf13295d8
parentd3ed6c06bd97e0e3fc4548f666cfc961f9cf7f49 (diff)
Revert some of the strlcpy() conversions which are wrong.
-rw-r--r--xenodm/file.c3
-rw-r--r--xenodm/resource.c9
-rw-r--r--xenodm/util.c7
3 files changed, 12 insertions, 7 deletions
diff --git a/xenodm/file.c b/xenodm/file.c
index 3fe73a4..d171048 100644
--- a/xenodm/file.c
+++ b/xenodm/file.c
@@ -89,7 +89,8 @@ splitIntoWords (char *s)
freeFileArgs (args);
return NULL;
}
- strlcpy (args[nargs], wordStart, s - wordStart);
+ strncpy (args[nargs], wordStart, s - wordStart);
+ args[nargs][s-wordStart] = '\0';
++nargs;
args[nargs] = NULL;
}
diff --git a/xenodm/resource.c b/xenodm/resource.c
index 7434320..ec61b3f 100644
--- a/xenodm/resource.c
+++ b/xenodm/resource.c
@@ -260,15 +260,18 @@ GetResource (
LogOutOfMem ("GetResource");
return;
}
- strlcpy (new_string, string, len);
+ strncpy (new_string, string, len);
+ new_string[len] = '\0';
*(valuep) = new_string;
break;
case DM_INT:
- strlcpy (str_buf, string, sizeof (str_buf));
+ strncpy (str_buf, string, sizeof (str_buf));
+ str_buf[sizeof (str_buf)-1] = '\0';
*((int *) valuep) = atoi (str_buf);
break;
case DM_BOOL:
- strlcpy (str_buf, string, sizeof (str_buf));
+ strncpy (str_buf, string, sizeof (str_buf));
+ str_buf[sizeof (str_buf)-1] = '\0';
XmuCopyISOLatin1Lowered (str_buf, str_buf);
if (!strcmp (str_buf, "true") ||
!strcmp (str_buf, "on") ||
diff --git a/xenodm/util.c b/xenodm/util.c
index a2397c8..8f6cfe5 100644
--- a/xenodm/util.c
+++ b/xenodm/util.c
@@ -136,7 +136,8 @@ putEnv(const char *string, char **env)
return NULL;
}
- strlcpy(n, string,nl + 1);
+ strlcpy(n, string, nl + 1);
+ n[nl] = 0;
env = setEnv(env,n,v);
free(n);
@@ -192,8 +193,8 @@ parseArgs (char **argv, const char *string)
} else {
argv = newargv;
}
- strlcpy (save, word, string-word);
- argv[i] = save;
+ argv[i] = strncpy (save, word, string-word);
+ argv[i][string-word] = '\0';
i++;
}
if (!*string)