From 7d19ed074bfea793e960c4f86af8085251ba613a Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 6 Aug 2005 06:27:05 +0000 Subject: Fix off by one memory allocation error --- common/textfile.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'common/textfile.c') 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; -- cgit