diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index b4be42bac..6bea4e80c 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,7 +1,8 @@ Version 1.02.06 - ============================= + Move DEFS into configure.h. Fix leaks in error paths found by coverity. - Increase dmsetup line buffer to 4k. + Remove dmsetup line buffer limitation. Version 1.02.05 - 19 Apr 2006 ============================= diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c index 406d369a9..a02f35d5c 100644 --- a/daemons/dmeventd/dmeventd.c +++ b/daemons/dmeventd/dmeventd.c @@ -16,6 +16,9 @@ * dmeventd - dm event daemon to monitor active mapped devices */ +#define _GNU_SOURCE +#define _FILE_OFFSET_BITS 64 + #include "libdevmapper.h" #include "libdevmapper-event.h" #include "list.h" diff --git a/tools/dmsetup.c b/tools/dmsetup.c index 80170c41f..d8a7cda66 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -19,6 +19,8 @@ #define _GNU_SOURCE #define _FILE_OFFSET_BITS 64 +#include + #include "libdevmapper.h" #include "log.h" @@ -117,7 +119,9 @@ static struct dm_tree *_dtree; */ static int _parse_file(struct dm_task *dmt, const char *file) { - char buffer[LINE_SIZE], ttype[LINE_SIZE], *ptr, *comment; + char *buffer = NULL; + size_t buffer_size = 0; + char ttype[LINE_SIZE], *ptr, *comment; FILE *fp; unsigned long long start, size; int r = 0, n, line = 0; @@ -132,7 +136,17 @@ static int _parse_file(struct dm_task *dmt, const char *file) } else fp = stdin; - while (fgets(buffer, sizeof(buffer), fp)) { +#ifndef HAVE_GETLINE + buffer_size = LINE_SIZE; + if (!(buffer = malloc(buffer_size))) { + err("Failed to malloc line buffer."); + return 0; + } + + while (fgets(buffer, buffer_size, fp)) { +#else + while (getline(&buffer, &buffer_size, fp) > 0) { +#endif line++; /* trim trailing space */ @@ -164,6 +178,7 @@ static int _parse_file(struct dm_task *dmt, const char *file) r = 1; out: + free(buffer); if (file) fclose(fp); return r;