Fix the segfault in get_calleridname if the From: string starts with "<sip:..."

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1079 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Martin Pycko 2003-06-08 16:26:08 +00:00
parent 731dccfccc
commit c680adba74
1 changed files with 5 additions and 2 deletions

View File

@ -3326,7 +3326,7 @@ static char *get_calleridname(char *input,char *output)
{ {
char *end = strchr(input,'<'); char *end = strchr(input,'<');
char *tmp = strchr(input,'\"'); char *tmp = strchr(input,'\"');
if (!end) return NULL; if (!end || (end == input)) return NULL;
/* move away from "<" */ /* move away from "<" */
end--; end--;
/* we found "name" */ /* we found "name" */
@ -3342,7 +3342,10 @@ static char *get_calleridname(char *input,char *output)
/* clear the empty characters in the end */ /* clear the empty characters in the end */
while(*end && (*end < 33) && end > input) while(*end && (*end < 33) && end > input)
end--; end--;
strncpy(output,input,(int)(end-input)); if (end > input)
strncpy(output,input,(int)(end-input));
else
output = NULL;
} }
return output; return output;
} }