Changeset 2726


Ignore:
Timestamp:
May 30, 2009 10:17:55 AM (10 years ago)
Author:
nanang
Message:

Ticket #862: Updated validations of SRTP crypto attribute.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c

    r2597 r2726  
    2323#include <pjlib-util/base64.h> 
    2424#include <pj/assert.h> 
     25#include <pj/ctype.h> 
    2526#include <pj/lock.h> 
    2627#include <pj/log.h> 
     
    981982    pj_str_t input; 
    982983    char *token; 
     984    int token_len; 
    983985    pj_str_t tmp; 
    984986    pj_status_t status; 
     
    994996        return PJMEDIA_SDP_EINATTR; 
    995997    } 
     998    token_len = pj_ansi_strlen(token); 
     999 
     1000    /* Tag must not use leading zeroes. */ 
     1001    if (token_len > 1 && *token == '0') 
     1002        return PJMEDIA_SDP_EINATTR; 
     1003 
     1004    /* Tag must be decimal, i.e: contains only digit '0'-'9'. */ 
     1005    for (itmp = 0; itmp < token_len; ++itmp) 
     1006        if (!pj_isdigit(token[itmp])) 
     1007            return PJMEDIA_SDP_EINATTR; 
     1008 
     1009    /* Get tag value. */ 
    9961010    *tag = atoi(token); 
    997     if (*tag == 0) 
    998         return PJMEDIA_SDP_EINATTR; 
    9991011 
    10001012    /* Crypto-suite */ 
Note: See TracChangeset for help on using the changeset viewer.