diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2005-08-06 06:27:05 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2005-08-06 06:27:05 +0000 |
commit | 7d19ed074bfea793e960c4f86af8085251ba613a (patch) | |
tree | 3363daad9f6eb4a1209ffc18e2ca0f077e8cc5f1 /common | |
parent | 6419dcad3732c1be03bbe570c6c64c82b33ad599 (diff) |
Fix off by one memory allocation error
Diffstat (limited to 'common')
-rw-r--r-- | common/textfile.c | 11 |
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; |