Skip to content

Commit

Permalink
Don't do strchr on a string that isn't necessarily null-terminated
Browse files Browse the repository at this point in the history
  • Loading branch information
mstorsjo committed Aug 15, 2013
1 parent 8e30642 commit ec606b6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion librtmp/rtmp.c
Expand Up @@ -2503,6 +2503,16 @@ static void hexenc(unsigned char *inbuf, int len, char *dst)
*ptr = '\0';
}

static char *
AValChr(AVal *av, char c)
{
int i;
for (i = 0; i < av->av_len; i++)
if (av->av_val[i] == c)
return &av->av_val[i];
return NULL;
}

static int
PublisherAuth(RTMP *r, AVal *description)
{
Expand Down Expand Up @@ -2774,7 +2784,7 @@ PublisherAuth(RTMP *r, AVal *description)
/* hash2 = hexenc(md5(method + ":/" + app + "/" + appInstance)) */
/* Extract appname + appinstance without query parameters */
apptmp = r->Link.app;
ptr = strchr(apptmp.av_val, '?');
ptr = AValChr(&apptmp, '?');
if (ptr)
apptmp.av_len = ptr - apptmp.av_val;

Expand Down

0 comments on commit ec606b6

Please sign in to comment.