summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPetr Cech <pcech@redhat.com>2016-02-18 06:33:53 -0500
committerLukas Slebodnik <lslebodn@redhat.com>2016-02-24 13:51:01 +0100
commit2dd75ea79a57615808754c0ce550786edbc17d69 (patch)
tree7659de310421ed217114402b4bf10212e1d2c707 /src
parent6977d7c84145ac69195be58b3330861b9b8a3b72 (diff)
downloadsssd-2dd75ea79a57615808754c0ce550786edbc17d69.tar.gz
sssd-2dd75ea79a57615808754c0ce550786edbc17d69.tar.xz
sssd-2dd75ea79a57615808754c0ce550786edbc17d69.zip
TOOLS: Fix memory leak after getline() failed
This patch fixes buffer freeing in case if getline() failed in function sss_colondb_readline(). ssize_t getline(char **lineptr, size_t *n, FILE *stream); If *lineptr is set to NULL and *n is set 0 before the call, then getline() will allocate a buffer for storing the line. This buffer should be freed by the user program even if getline() failed. man 3 getline This patch fix buffer freeing in case if getline() failed. Resolves: https://fedorahosted.org/sssd/ticket/2764 Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/tools/common/sss_colondb.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/tools/common/sss_colondb.c b/src/tools/common/sss_colondb.c
index b9af5f7e5..e8aeb315c 100644
--- a/src/tools/common/sss_colondb.c
+++ b/src/tools/common/sss_colondb.c
@@ -121,6 +121,10 @@ errno_t sss_colondb_readline(TALLOC_CTX *mem_ctx,
readchars = getline(&line, &linelen, db->file);
if (readchars == -1) {
/* Nothing was read. */
+
+ free(line);
+ line = NULL;
+
if (errno != 0) {
ret = errno;
DEBUG(SSSDBG_CRIT_FAILURE, "Unable to read line [%d]: %s\n",