From ac83e19fc4f6baf35f9c0c268bd0ffd2577a3aed Mon Sep 17 00:00:00 2001 From: Morris Jette <jette@schedmd.com> Date: Fri, 26 Jun 2015 13:20:12 -0700 Subject: [PATCH] Fix to layouts logic logic was generating invalid size unpack error --- src/common/layouts_mgr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/common/layouts_mgr.c b/src/common/layouts_mgr.c index 4c9b82a5a3c..87583711ae6 100644 --- a/src/common/layouts_mgr.c +++ b/src/common/layouts_mgr.c @@ -2636,9 +2636,9 @@ int layouts_autoupdate_layout(char *l_type) int layouts_state_save_layout(char* l_type) { - int error_code = 0, log_fd; + int error_code = 0, log_fd, offset; char *old_file = NULL, *new_file = NULL, *reg_file = NULL; - static int high_buffer_size = (1024 * 1024); + static int high_buffer_size = (16 * 1024); Buf buffer = init_buf(high_buffer_size); FILE* fdump; uint32_t utmp32, record_count = 0; @@ -2656,6 +2656,8 @@ int layouts_state_save_layout(char* l_type) } /* rewind the freshly created buffer to unpack it into a file */ + offset = get_buf_offset(buffer); + high_buffer_size = MAX(high_buffer_size, offset); set_buf_offset(buffer, 0); /* create working files */ @@ -2673,7 +2675,7 @@ int layouts_state_save_layout(char* l_type) safe_unpack32(&record_count, buffer); debug("layouts/%s: dumping %u records into state file", l_type, record_count); - while (remaining_buf(buffer) > 0) { + while (get_buf_offset(buffer) < offset) { safe_unpackstr_xmalloc(&tmp_str, &utmp32, buffer); if (tmp_str != NULL) { if (*tmp_str == '\0') { -- GitLab