Changeset 5520 for pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c
- Timestamp:
- Jan 11, 2017 4:38:29 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c
r5500 r5520 1217 1217 int *tag) 1218 1218 { 1219 pj_str_t input; 1220 char *token; 1221 pj_str_t tmp; 1219 pj_str_t token, delim; 1222 1220 pj_status_t status; 1223 int itmp, token_len;1221 int itmp, found_idx; 1224 1222 1225 1223 pj_bzero(crypto, sizeof(*crypto)); 1226 pj_strdup_with_null(pool, &input, &attr->value);1227 1224 1228 1225 /* Tag */ 1229 token = strtok(input.ptr, " "); 1230 if (!token) { 1226 delim = pj_str(" "); 1227 found_idx = pj_strtok(&attr->value, &delim, &token, 0); 1228 if (found_idx == attr->value.slen) { 1231 1229 PJ_LOG(4,(THIS_FILE, "Attribute crypto expecting tag")); 1232 1230 return PJMEDIA_SDP_EINATTR; 1233 1231 } 1234 token_len = pj_ansi_strlen(token);1235 1232 1236 1233 /* Tag must not use leading zeroes. */ 1237 if (token _len > 1 && *token== '0')1234 if (token.slen > 1 && *token.ptr == '0') 1238 1235 return PJMEDIA_SDP_EINATTR; 1239 1236 1240 1237 /* Tag must be decimal, i.e: contains only digit '0'-'9'. */ 1241 for (itmp = 0; itmp < token _len; ++itmp)1242 if (!pj_isdigit(token [itmp]))1238 for (itmp = 0; itmp < token.slen; ++itmp) 1239 if (!pj_isdigit(token.ptr[itmp])) 1243 1240 return PJMEDIA_SDP_EINATTR; 1244 1241 1245 1242 /* Get tag value. */ 1246 *tag = atoi(token);1243 *tag = pj_strtoul(&token); 1247 1244 1248 1245 /* Crypto-suite */ 1249 token = strtok(NULL, " ");1250 if ( !token) {1246 found_idx = pj_strtok(&attr->value, &delim, &token, found_idx+token.slen); 1247 if (found_idx == attr->value.slen) { 1251 1248 PJ_LOG(4,(THIS_FILE, "Attribute crypto expecting crypto suite")); 1252 1249 return PJMEDIA_SDP_EINATTR; 1253 1250 } 1254 crypto->name = pj_str(token);1251 crypto->name = token; 1255 1252 1256 1253 /* Key method */ 1257 token = strtok(NULL, ":"); 1258 if (!token) { 1254 delim = pj_str(": "); 1255 found_idx = pj_strtok(&attr->value, &delim, &token, found_idx+token.slen); 1256 if (found_idx == attr->value.slen) { 1259 1257 PJ_LOG(4,(THIS_FILE, "Attribute crypto expecting key method")); 1260 1258 return PJMEDIA_SDP_EINATTR; 1261 1259 } 1262 if (pj_ ansi_stricmp(token, "inline")) {1263 PJ_LOG(4,(THIS_FILE, "Attribute crypto key method '% s' not supported!",1264 token));1260 if (pj_stricmp2(&token, "inline")) { 1261 PJ_LOG(4,(THIS_FILE, "Attribute crypto key method '%.*s' " 1262 "not supported!", token.slen, token.ptr)); 1265 1263 return PJMEDIA_SDP_EINATTR; 1266 1264 } 1267 1265 1268 /* Key */ 1269 token = strtok(NULL, "| "); 1270 if (!token) { 1266 /* Key */ 1267 delim = pj_str("| "); 1268 found_idx = pj_strtok(&attr->value, &delim, &token, found_idx+token.slen); 1269 if (found_idx == attr->value.slen) { 1271 1270 PJ_LOG(4,(THIS_FILE, "Attribute crypto expecting key")); 1272 1271 return PJMEDIA_SDP_EINATTR; 1273 1272 } 1274 tmp = pj_str(token);1275 if (PJ_BASE64_TO_BASE256_LEN(t mp.slen) > MAX_KEY_LEN) {1273 1274 if (PJ_BASE64_TO_BASE256_LEN(token.slen) > MAX_KEY_LEN) { 1276 1275 PJ_LOG(4,(THIS_FILE, "Key too long")); 1277 1276 return PJMEDIA_SRTP_EINKEYLEN; … … 1281 1280 crypto->key.ptr = (char*) pj_pool_zalloc(pool, MAX_KEY_LEN); 1282 1281 itmp = MAX_KEY_LEN; 1283 status = pj_base64_decode(&t mp, (pj_uint8_t*)crypto->key.ptr,1282 status = pj_base64_decode(&token, (pj_uint8_t*)crypto->key.ptr, 1284 1283 &itmp); 1285 1284 if (status != PJ_SUCCESS) {
Note: See TracChangeset
for help on using the changeset viewer.