Bugzilla – Bug 182
serverdb is saved out with missing data
Last modified: 2012-05-03 13:57:32 MDT
You need to log in before you can comment on or make changes to this bug.
The server DB is corrupted on save in 4.0.1 r6023, but the following patch fixes it. The bug is that attr_to_str calls size_to_dynamic_string assuming it will append to the string, when it currently replaces it. It looked to me like it was supposed to append, so the following shortens and corrects size_to_dynamic_string I'm not 100% convinced this is doing the right thing, my server DB currently says that we've got 67645734912kb of memory allocated, with is ~63TB. If that were bytes, it'd be about right. I wonder if the code also needs a case for szv.atsv_shift=0 or similar? Index: src/lib/Libutils/u_dynamic_string.c =================================================================== --- src/lib/Libutils/u_dynamic_string.c (revision 6023) +++ src/lib/Libutils/u_dynamic_string.c (working copy) @@ -155,55 +155,36 @@ { char buffer[MAXLINE]; - int add_one = FALSE; - - if (ds->used == 0) - add_one = TRUE; - + size_t str_size = 0; + + // We insert any old suffix to start with and fix it below: sprintf(buffer, "%lukb", szv.atsv_num); - resize_if_needed(ds, buffer); - - sprintf(buffer, "%lu", szv.atsv_num); - strcat(ds->str, buffer); + str_size = strlen( buffer ); switch (szv.atsv_shift) { case 10: - - strcat(ds->str, "kb"); - + buffer[str_size - 2] = 'k'; break; case 20: - - strcat(ds->str, "mb"); - + buffer[str_size - 2] = 'm'; break; case 30: - - strcat(ds->str, "gb"); - + buffer[str_size - 2] = 'g'; break; case 40: - - strcat(ds->str, "tb"); - + buffer[str_size - 2] = 't'; break; case 50: - - strcat(ds->str, "pb"); - + buffer[str_size - 2] = 'p'; break; } - - ds->used += strlen(buffer) + 2; - if (add_one == TRUE) - ds->used += 1; - - return(PBSE_NONE); + + return append_dynamic_string( ds, buffer ); } /* END size_to_dynamic_string() */
Committed to 4.0.2