mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Trap large memory allocation requests.
This commit is contained in:
parent
2e6051674b
commit
c3a4c63c15
@ -1,5 +1,6 @@
|
|||||||
Version 2.00.27 - 24th November 2004
|
Version 2.00.27 - 24th November 2004
|
||||||
====================================
|
====================================
|
||||||
|
Trap large memory allocation requests.
|
||||||
Fix to partition table detection code.
|
Fix to partition table detection code.
|
||||||
Improve filter debug mesgs.
|
Improve filter debug mesgs.
|
||||||
|
|
||||||
|
@ -76,6 +76,7 @@ SOURCES =\
|
|||||||
misc/crc.c \
|
misc/crc.c \
|
||||||
misc/lvm-file.c \
|
misc/lvm-file.c \
|
||||||
misc/lvm-string.c \
|
misc/lvm-string.c \
|
||||||
|
mm/dbg_malloc.c \
|
||||||
mm/memlock.c \
|
mm/memlock.c \
|
||||||
mm/pool.c \
|
mm/pool.c \
|
||||||
regex/matcher.c \
|
regex/matcher.c \
|
||||||
@ -121,10 +122,6 @@ ifeq ("@MIRRORS@", "internal")
|
|||||||
SOURCES += mirror/mirrored.c
|
SOURCES += mirror/mirrored.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ("@DEBUG@", "yes")
|
|
||||||
SOURCES += mm/dbg_malloc.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ("@DEVMAPPER@", "yes")
|
ifeq ("@DEVMAPPER@", "yes")
|
||||||
SOURCES +=\
|
SOURCES +=\
|
||||||
activate/dev_manager.c \
|
activate/dev_manager.c \
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#ifdef DEBUG_MEM
|
||||||
|
|
||||||
struct memblock {
|
struct memblock {
|
||||||
struct memblock *prev, *next; /* All allocated blocks are linked */
|
struct memblock *prev, *next; /* All allocated blocks are linked */
|
||||||
size_t length; /* Size of the requested block */
|
size_t length; /* Size of the requested block */
|
||||||
@ -47,7 +49,7 @@ void *malloc_aux(size_t s, const char *file, int line)
|
|||||||
|
|
||||||
if (s > 50000000) {
|
if (s > 50000000) {
|
||||||
log_error("Huge memory allocation (size %" PRIuPTR
|
log_error("Huge memory allocation (size %" PRIuPTR
|
||||||
") rejected - bug?", s);
|
") rejected - metadata corruption?", s);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +168,6 @@ void *realloc_aux(void *p, unsigned int s, const char *file, int line)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MEM
|
|
||||||
int dump_memory(void)
|
int dump_memory(void)
|
||||||
{
|
{
|
||||||
unsigned long tot = 0;
|
unsigned long tot = 0;
|
||||||
@ -213,10 +214,18 @@ void bounds_check(void)
|
|||||||
mb = mb->next;
|
mb = mb->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
#else
|
||||||
* Local variables:
|
|
||||||
* c-file-style: "linux"
|
void *malloc_aux(size_t s, const char *file, int line)
|
||||||
* End:
|
{
|
||||||
*/
|
if (s > 50000000) {
|
||||||
|
log_error("Huge memory allocation (size %" PRIuPTR
|
||||||
|
") rejected - metadata corruption?", s);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return malloc(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -20,22 +20,26 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef DEBUG_MEM
|
|
||||||
void *malloc_aux(size_t s, const char *file, int line);
|
void *malloc_aux(size_t s, const char *file, int line);
|
||||||
|
# define dbg_malloc(s) malloc_aux((s), __FILE__, __LINE__)
|
||||||
|
|
||||||
|
#ifdef DEBUG_MEM
|
||||||
|
|
||||||
void free_aux(void *p);
|
void free_aux(void *p);
|
||||||
void *realloc_aux(void *p, unsigned int s, const char *file, int line);
|
void *realloc_aux(void *p, unsigned int s, const char *file, int line);
|
||||||
int dump_memory(void);
|
int dump_memory(void);
|
||||||
void bounds_check(void);
|
void bounds_check(void);
|
||||||
|
|
||||||
# define dbg_malloc(s) malloc_aux((s), __FILE__, __LINE__)
|
|
||||||
# define dbg_free(p) free_aux(p)
|
# define dbg_free(p) free_aux(p)
|
||||||
# define dbg_realloc(p, s) realloc_aux(p, s, __FILE__, __LINE__)
|
# define dbg_realloc(p, s) realloc_aux(p, s, __FILE__, __LINE__)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# define dbg_malloc(s) malloc(s)
|
|
||||||
# define dbg_free(p) free(p)
|
# define dbg_free(p) free(p)
|
||||||
# define dbg_realloc(p, s) realloc(p, s)
|
# define dbg_realloc(p, s) realloc(p, s)
|
||||||
# define dump_memory()
|
# define dump_memory()
|
||||||
# define bounds_check()
|
# define bounds_check()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline char *dbg_strdup(const char *str)
|
static inline char *dbg_strdup(const char *str)
|
||||||
|
Loading…
Reference in New Issue
Block a user