From c51810738eb8becea104afb4adc112ff393ece71 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Thu, 20 Jun 2013 01:45:29 +0000 Subject: [PATCH] Improve handling of one kind of malformed CDCC save file, where the pack description line doesn't contain a space. Found by Coverity. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@244 13b04d17-f746-0410-82c6-800466cd88b0 --- Changelog | 2 ++ source/cdcc.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) 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);