Strncpy is a disgrace. - rfkilld - An rfkill daemon, which runs scripts according to rfkill events.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 3bd645cd25ec87fbcdbc1e98c39dc9b8eccb5417
(DIR) parent 398d2905b1b9bef02c7b11c687a408036da2c212
(HTM) Author: Christoph Lohmann <20h@r-36.net>
Date: Mon, 21 Mar 2011 10:16:45 +0100
Strncpy is a disgrace.
Diffstat:
rfkilld.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/rfkilld.c b/rfkilld.c
@@ -47,8 +47,10 @@ runifexecutable(char *file, char *oname, char *ostate)
char cmd[512], name[64], state[16];
int pid;
- strncpy(name, oname, sizeof(name));
- strncpy(state, ostate, sizeof(state));
+ strncpy(name, oname, sizeof(name)-1);
+ name[sizeof(name)-1] = '\0';
+ strncpy(state, ostate, sizeof(state)-1);
+ state[sizeof(state)-1] = '\0';
snprintf(cmd, sizeof(cmd), "%s/%s.sh", etcdir, file);
if (!access(cmd, X_OK)) {