summaryrefslogtreecommitdiffstats
path: root/common/textfile.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2005-08-06 06:27:05 +0000
committerMarcel Holtmann <marcel@holtmann.org>2005-08-06 06:27:05 +0000
commit7d19ed074bfea793e960c4f86af8085251ba613a (patch)
tree3363daad9f6eb4a1209ffc18e2ca0f077e8cc5f1 /common/textfile.c
parent6419dcad3732c1be03bbe570c6c64c82b33ad599 (diff)
Fix off by one memory allocation error
Diffstat (limited to 'common/textfile.c')
-rw-r--r--common/textfile.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/common/textfile.c b/common/textfile.c
index ca6f08f3..08cd5a9f 100644
--- a/common/textfile.c
+++ b/common/textfile.c
@@ -75,18 +75,15 @@ static int create_dirs(char *filename, mode_t mode)
return 0;
}
-static int write_key_value(int fd, char *key, char *value)
+static inline int write_key_value(int fd, char *key, char *value)
{
char *str;
- int size, err = 0;
-
- /* This check is needed, because other it will segfault */
- if (strlen(value) == 9)
- return -EIO;
+ size_t size;
+ int err = 0;
size = strlen(key) + strlen(value) + 2;
- str = malloc(size);
+ str = malloc(size + 1);
if (!str)
return ENOMEM;