Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.2:Update
makedumpfile
makedumpfile-sadump-0001-fixsegfault.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File makedumpfile-sadump-0001-fixsegfault.patch of Package makedumpfile
From: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com> Date: Mon Jun 20 14:58:05 2016 +0900 Subject: sadump: fix segmentation fault on sadump-related formats References: bsc#999869 Git-commit: 8edf033f0eada8640f821ea8abd5bc2b0fa09083 Patch-mainline: Released-1-6-1? Currently, makedumpfile results in segmentation fault on sadump-related formats: # ~/makedumpfile --message-level 31 -l -d 31 -x ./vmlinux vmcore sadump: read dump device as single partition sadump: single partition configuration page_size : 4096 Segmentation fault This is because although commit 5fc24bf754fa6d2c0bd0f1c6f5655de371efb9d5 started dynamically allocating the buffer of struct dump_bitmap, the sadump source code doesn't follow the change. This commit fixes this by following the change. Signed-off-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com> Acked-by: Petr Tesarik <ptesarik@suse.com> diff --git a/makedumpfile.c b/makedumpfile.c index fd884d3..ee3174f 100644 --- a/makedumpfile.c +++ b/makedumpfile.c @@ -11245,8 +11245,11 @@ out: free(info->kh_memory); if (info->valid_pages) free(info->valid_pages); - if (info->bitmap_memory) + if (info->bitmap_memory) { + if (info->bitmap_memory->buf) + free(info->bitmap_memory->buf); free(info->bitmap_memory); + } if (info->fd_memory) close(info->fd_memory); if (info->fd_dumpfile) diff --git a/sadump_info.c b/sadump_info.c index 20376f0..8716167 100644 --- a/sadump_info.c +++ b/sadump_info.c @@ -832,18 +832,28 @@ sadump_initialize_bitmap_memory(void) strerror(errno)); return FALSE; } + bmp->fd = info->fd_memory; bmp->file_name = info->name_memory; bmp->no_block = -1; - memset(bmp->buf, 0, BUFSIZE_BITMAP); bmp->offset = dumpable_bitmap_offset; + bmp->buf = malloc(BUFSIZE_BITMAP); + if (!bmp->buf) { + ERRMSG("Can't allocate memory for the memory-bitmap's buffer. %s\n", + strerror(errno)); + free(bmp); + return FALSE; + } + memset(bmp->buf, 0, BUFSIZE_BITMAP); + max_section = divideup(si->max_mapnr, SADUMP_PF_SECTION_NUM); block_table = calloc(sizeof(unsigned long long), max_section); if (block_table == NULL) { ERRMSG("Can't allocate memory for the block_table. %s\n", strerror(errno)); + free(bmp->buf); free(bmp); return FALSE; } @@ -870,8 +880,17 @@ sadump_initialize_bitmap_memory(void) bmp->fd = info->fd_memory; bmp->file_name = info->name_memory; bmp->no_block = -1; - memset(bmp->buf, 0, BUFSIZE_BITMAP); bmp->offset = si->sub_hdr_offset + sh->block_size * sh->sub_hdr_size; + + bmp->buf = malloc(BUFSIZE_BITMAP); + if (!bmp->buf) { + ERRMSG("Can't allocate memory for the memory-bitmap's buffer. %s\n", + strerror(errno)); + free(bmp); + return FALSE; + } + memset(bmp->buf, 0, BUFSIZE_BITMAP); + si->ram_bitmap = bmp; /* @@ -1904,6 +1923,11 @@ free_sadump_info(void) fclose(si->file_elf_note); if (si->cpu_online_mask_buf) free(si->cpu_online_mask_buf); + if (si->ram_bitmap) { + if (si->ram_bitmap->buf) + free(si->ram_bitmap->buf); + free(si->ram_bitmap); + } } void
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor