diff --git a/Changelog b/Changelog index 9ca3933..3889fcc 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ [Changes 1.2c01] +* Improve robustness of CDCC save file loading. (caf) + * Fix open file leak in /LASTLOG found by Coverity. (caf) * Fix file descriptor leak on SOCKS4 connection failure found by diff --git a/source/cdcc.c b/source/cdcc.c index 5544eaf..2e557ae 100644 --- a/source/cdcc.c +++ b/source/cdcc.c @@ -1182,11 +1182,11 @@ static int l_load(char *args, char *rest) chop(buffer, 1); temp = strrchr(buffer, ' '); - *temp = '\0'; - temp++; + if (temp) + *temp++ = '\0'; malloc_strcpy(&ptr->desc, buffer); - if (*temp && !isdigit((unsigned char)*temp)) + if (!temp || !isdigit((unsigned char)*temp)) { put_it("%s: not a cdcc pack aborting", cparse(get_string_var(CDCC_PROMPT_VAR))); new_free(&ptr->file);