32236736a4
This commit fixes a memory corruption bug when parsing lines of the form: -x FOO=bar The code was making changes to the size of the buffer allocated for key_buffer without making the appropriate changes to key_buffer_len. This was causing subsequent calls to save_param_name to write to invalid memory. This commit makes the following changes: - Fix the above bug by modifying trim_name to move the string within the buffer instead of re-allocating space for the trimmed string. - Cleaned up both trim_name and save_param_name. Both functions took a prefix and suffix to trim. Problem was the prefix was not treated like a prefix. Instead the "prefix" was located inside the string using strstr then the trimmed value started after the substring (even in the middle of the string). To allow trimming both -x and --x (as well as -mca and --mca) trim_name is now called with each prefix. Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>