Changeset 4613
- Timestamp:
- Oct 8, 2013 9:08:13 AM (11 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjlib-util/dns_dump.c
r3553 r4613 37 37 if (ttl > DAY) { 38 38 len = pj_ansi_snprintf(p, size, "%dd ", ttl/DAY); 39 if (len < 1 )39 if (len < 1 || len >= size) 40 40 return "-err-"; 41 41 size -= len; … … 46 46 if (ttl > HOUR) { 47 47 len = pj_ansi_snprintf(p, size, "%dh ", ttl/HOUR); 48 if (len < 1 )48 if (len < 1 || len >= size) 49 49 return "-err-"; 50 50 size -= len; … … 55 55 if (ttl > MINUTE) { 56 56 len = pj_ansi_snprintf(p, size, "%dm ", ttl/MINUTE); 57 if (len < 1 )57 if (len < 1 || len >= size) 58 58 return "-err-"; 59 59 size -= len; … … 64 64 if (ttl > 0) { 65 65 len = pj_ansi_snprintf(p, size, "%ds ", ttl); 66 if (len < 1 )66 if (len < 1 || len >= size) 67 67 return "-err-"; 68 68 size -= len; -
pjproject/trunk/pjlib-util/src/pjlib-util/errno.c
r4440 r4613 167 167 "Unknown pjlib-util error %d", 168 168 statcode); 169 169 if (errstr.slen < 1 || errstr.slen >= (pj_ssize_t)bufsize) 170 errstr.slen = bufsize - 1; 170 171 return errstr; 171 172 } -
pjproject/trunk/pjlib-util/src/pjlib-util/http_client.c
r4537 r4613 1359 1359 if (chal->qop.slen == 0) { 1360 1360 const pj_str_t STR_MD5 = { "MD5", 3 }; 1361 int max_len; 1361 1362 1362 1363 /* Server doesn't require quality of protection. */ … … 1366 1367 &hreq->param.method); 1367 1368 1369 max_len = len; 1368 1370 len = pj_ansi_snprintf( 1369 phdr->value.ptr, len,1371 phdr->value.ptr, max_len, 1370 1372 "Digest username=\"%.*s\", " 1371 1373 "realm=\"%.*s\", " … … 1380 1382 STR_PREC(STR_MD5), 1381 1383 STR_PREC(digest_response)); 1382 if (len < 0 )1384 if (len < 0 || len >= max_len) 1383 1385 return PJ_ETOOSMALL; 1384 1386 phdr->value.slen = len; … … 1392 1394 const pj_str_t nc = pj_str("00000001"); 1393 1395 const pj_str_t cnonce = pj_str("b39971"); 1396 int max_len; 1394 1397 1395 1398 auth_create_digest_response(&digest_response, cred, … … 1397 1400 &hreq->hurl.path, &chal->realm, 1398 1401 &hreq->param.method); 1402 max_len = len; 1399 1403 len = pj_ansi_snprintf( 1400 phdr->value.ptr, len,1404 phdr->value.ptr, max_len, 1401 1405 "Digest username=\"%.*s\", " 1402 1406 "realm=\"%.*s\", " … … 1417 1421 STR_PREC(nc), 1418 1422 STR_PREC(cnonce)); 1419 if (len < 0 )1423 if (len < 0 || len >= max_len) 1420 1424 return PJ_ETOOSMALL; 1421 1425 phdr->value.slen = len; -
pjproject/trunk/pjlib/src/pj/errno.c
r4537 r4613 92 92 static int pjlib_error(pj_status_t code, char *buf, pj_size_t size) 93 93 { 94 int len; 95 94 96 #if defined(PJ_HAS_ERROR_STRING) && PJ_HAS_ERROR_STRING!=0 95 97 unsigned i; … … 106 108 #endif 107 109 108 return pj_ansi_snprintf( buf, size, "Unknown pjlib error %d", code); 110 len = pj_ansi_snprintf( buf, size, "Unknown pjlib error %d", code); 111 if (len < 1 || len >= (int)size) 112 len = size - 1; 113 return len; 109 114 } 110 115 … … 200 205 } 201 206 202 if (len < 1 ) {203 *buf = '\0';204 len = 0;207 if (len < 1 || len >= (int)bufsize) { 208 len = bufsize - 1; 209 buf[len] = '\0'; 205 210 } 206 211 -
pjproject/trunk/pjlib/src/pj/lock.c
r4412 r4613 684 684 685 685 len = pj_ansi_snprintf(start, max_len, "%s:%d ", ref->file, ref->line); 686 if (len < 1 || len > max_len) {686 if (len < 1 || len >= max_len) { 687 687 len = strlen(ref->file); 688 688 if (len > max_len - 1) -
pjproject/trunk/pjlib/src/pj/log.c
r4537 r4613 446 446 "<logging error: msg too long>"); 447 447 } 448 if (print_len < 1 || print_len >= (int)(sizeof(log_buffer)-len)) { 449 print_len = sizeof(log_buffer) - len - 1; 450 } 448 451 len = len + print_len; 449 452 if (len > 0 && len < (int)sizeof(log_buffer)-2) { -
pjproject/trunk/pjlib/src/pj/os_error_symbian.cpp
r3553 r4613 163 163 164 164 if (!len) { 165 len = pj_ansi_snprintf( buf, bufsize , "Symbian native error %d",165 len = pj_ansi_snprintf( buf, bufsize-1, "Symbian native error %d", 166 166 os_errcode); 167 167 buf[len] = '\0'; -
pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
r4537 r4613 273 273 "Unknown OpenSSL error %lu", 274 274 ssl_err); 275 275 if (errstr.slen < 1 || errstr.slen >= (int)bufsize) 276 errstr.slen = bufsize - 1; 276 277 return errstr; 277 278 } -
pjproject/trunk/pjmedia/src/pjmedia-audiodev/alsa_dev.c
r4283 r4613 172 172 { 173 173 char err_msg[128]; 174 int index ;174 int index, len; 175 175 va_list arg; 176 176 … … 181 181 index = snprintf (err_msg, sizeof(err_msg), "ALSA lib: "); 182 182 #endif 183 if (index < 1 || index >= (int)sizeof(err_msg)) { 184 index = sizeof(err_msg)-1; 185 err_msg[index] = '\0'; 186 goto print_msg; 187 } 188 183 189 va_start (arg, fmt); 184 if (index < sizeof(err_msg)-1) 185 index += vsnprintf (err_msg+index, sizeof(err_msg)-index, fmt, arg); 190 if (index < sizeof(err_msg)-1) { 191 len = vsnprintf( err_msg+index, sizeof(err_msg)-index, fmt, arg); 192 if (len < 1 || len >= (int)sizeof(err_msg)-index) 193 len = sizeof(err_msg)-index-1; 194 index += len; 195 err_msg[index] = '\0'; 196 } 186 197 va_end(arg); 187 if (err && index < sizeof(err_msg)-1) 188 index += snprintf (err_msg+index, sizeof(err_msg)-index, ": %s", 189 snd_strerror(err)); 198 if (err && index < sizeof(err_msg)-1) { 199 len = snprintf( err_msg+index, sizeof(err_msg)-index, ": %s", 200 snd_strerror(err)); 201 if (len < 1 || len >= (int)sizeof(err_msg)-index) 202 len = sizeof(err_msg)-index-1; 203 index += len; 204 err_msg[index] = '\0'; 205 } 206 print_msg: 190 207 PJ_LOG (4,(THIS_FILE, "%s", err_msg)); 191 208 } -
pjproject/trunk/pjmedia/src/pjmedia-audiodev/errno.c
r4537 r4613 215 215 "Unknown pjmedia-audiodev error %d", 216 216 statcode); 217 217 if (errstr.slen < 1 || errstr.slen >= (pj_ssize_t)bufsize) 218 errstr.slen = bufsize - 1; 218 219 return errstr; 219 220 } -
pjproject/trunk/pjmedia/src/pjmedia-videodev/errno.c
r3715 r4613 112 112 "Unknown pjmedia-videodev error %d", 113 113 statcode); 114 114 if (errstr.slen < 1 || errstr.slen >= (pj_ssize_t)bufsize) 115 errstr.slen = bufsize - 1; 115 116 return errstr; 116 117 } -
pjproject/trunk/pjmedia/src/pjmedia/endpoint.c
r4537 r4613 491 491 492 492 /* Print codec PT */ 493 buf_len += pj_ansi_snprintf(buf, 494 MAX_FMTP_STR_LEN - buf_len, 495 "%d", 493 buf_len += pj_ansi_snprintf(buf, 494 MAX_FMTP_STR_LEN - buf_len, 495 "%d", 496 496 codec_info->pt); 497 497 … … 501 501 /* Check if buf still available */ 502 502 test_len = dec_fmtp->param[i].val.slen + 503 dec_fmtp->param[i].name.slen ;503 dec_fmtp->param[i].name.slen + 2; 504 504 if (test_len + buf_len >= MAX_FMTP_STR_LEN) 505 505 return PJ_ETOOBIG; … … 687 687 /* Check if buf still available */ 688 688 test_len = dec_fmtp->param[j].val.slen + 689 dec_fmtp->param[j].name.slen ;689 dec_fmtp->param[j].name.slen + 2; 690 690 if (test_len + buf_len >= MAX_FMTP_STR_LEN) 691 691 return PJ_ETOOBIG; -
pjproject/trunk/pjmedia/src/pjmedia/errno.c
r3945 r4613 267 267 "Unknown pjmedia error %d", 268 268 statcode); 269 269 if (errstr.slen < 1 || errstr.slen >= (pj_ssize_t)bufsize) 270 errstr.slen = bufsize - 1; 270 271 return errstr; 271 272 } -
pjproject/trunk/pjmedia/src/pjmedia/ffmpeg_util.c
r4537 r4613 115 115 AVClass* avc = *(AVClass**)ptr; 116 116 len = pj_ansi_snprintf(buf, bufsize, "%s: ", avc->item_name(ptr)); 117 if (len < 1 || len >= bufsize) 118 len = bufsize - 1; 117 119 bufsize -= len; 118 120 } -
pjproject/trunk/pjmedia/src/pjmedia/sdp.c
r4537 r4613 504 504 rtpmap->param.ptr); 505 505 506 if (len < 1 || len > (int)sizeof(tempbuf))506 if (len < 1 || len >= (int)sizeof(tempbuf)) 507 507 return PJMEDIA_SDP_ERTPMAPTOOLONG; 508 508 … … 527 527 (int)c->addr.slen, 528 528 c->addr.ptr); 529 if (printed < 1 || printed > len)529 if (printed < 1 || printed >= len) 530 530 return -1; 531 531 -
pjproject/trunk/pjmedia/src/pjmedia/stream.c
r4537 r4613 2412 2412 "Frame type, RTP Seq, RTP TS, RTP M, " 2413 2413 "JB size, JB burst level, JB prefetch\n"); 2414 if (len < 1 || len >= PJ_LOG_MAX_SIZE) 2415 len = PJ_LOG_MAX_SIZE-1; 2414 2416 pj_file_write(stream->trace_jb_fd, stream->trace_jb_buf, &len); 2415 2417 pj_file_flush(stream->trace_jb_fd); -
pjproject/trunk/pjmedia/src/pjmedia/transport_ice.c
r4606 r4613 350 350 break; 351 351 } 352 if (len2 < 1 || len2 >= max_len )352 if (len2 < 1 || len2 >= max_len-len) 353 353 return -1; 354 354 … … 546 546 pj_sockaddr_get_port(&check->rcand->addr) 547 547 ); 548 if (len < 1 || len >= RATTR_BUF_LEN ) {548 if (len < 1 || len >= RATTR_BUF_LEN - rem_cand.slen) { 549 549 pj_assert(!"Not enough buffer to print " 550 550 "remote-candidates"); -
pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c
r4537 r4613 1044 1044 char b64_key[PJ_BASE256_TO_BASE64_LEN(MAX_KEY_LEN)+1]; 1045 1045 int b64_key_len = sizeof(b64_key); 1046 int print_len; 1046 1047 1047 1048 if (cs_idx == -1) … … 1102 1103 1103 1104 /* Print the crypto attribute value. */ 1104 *buffer_len = pj_ansi_snprintf(buffer, *buffer_len, "%d %s inline:%s",1105 print_len = pj_ansi_snprintf(buffer, *buffer_len, "%d %s inline:%s", 1105 1106 tag, 1106 1107 crypto_suites[cs_idx].name, 1107 1108 b64_key); 1109 if (print_len < 1 || print_len >= *buffer_len) 1110 return PJ_ETOOSMALL; 1111 1112 *buffer_len = print_len; 1108 1113 1109 1114 return PJ_SUCCESS; -
pjproject/trunk/pjmedia/src/pjmedia/vid_stream.c
r4537 r4613 1651 1651 "Frame type, RTP Seq, RTP TS, RTP M, " 1652 1652 "JB size, JB burst level, JB prefetch\n"); 1653 if (len < 1 || len >= PJ_LOG_MAX_SIZE) 1654 len = PJ_LOG_MAX_SIZE - 1; 1653 1655 pj_file_write(stream->trace_jb_fd, stream->trace_jb_buf, &len); 1654 1656 pj_file_flush(stream->trace_jb_fd); -
pjproject/trunk/pjnath/src/pjnath/errno.c
r3553 r4613 134 134 "Unknown pjnath error %d", 135 135 statcode); 136 if (errstr.slen < 0) errstr.slen = 0;137 else if (errstr.slen > (int)bufsize) errstr.slen = bufsize;136 if (errstr.slen < 1 || errstr.slen >= (int)bufsize) 137 errstr.slen = bufsize-1; 138 138 139 139 return errstr; … … 165 165 } 166 166 167 if (errstr.slen < 0) errstr.slen = 0;168 else if (errstr.slen > (int)bufsize) errstr.slen = bufsize;167 if (errstr.slen < 1 || errstr.slen >= (int)bufsize) 168 errstr.slen = bufsize-1; 169 169 170 170 return errstr; -
pjproject/trunk/pjnath/src/pjnath/stun_msg.c
r4537 r4613 2452 2452 err_msg1, 2453 2453 pj_stun_get_attr_name(attr_type)); 2454 2454 if (e.slen < 1 || e.slen >= (int)sizeof(err_msg2)) 2455 e.slen = sizeof(err_msg2) - 1; 2455 2456 pj_stun_msg_create_response(pool, msg, 2456 2457 PJ_STUN_SC_BAD_REQUEST, -
pjproject/trunk/pjsip-apps/src/samples/icedemo.c
r4537 r4613 518 518 printed = pj_ansi_snprintf(p, maxlen - (p-buffer), \ 519 519 fmt, arg0, arg1, arg2, arg3, arg4, arg5); \ 520 if (printed <= 0) return -PJ_ETOOSMALL; \ 520 if (printed <= 0 || printed >= (int)(maxlen - (p-buffer))) \ 521 return -PJ_ETOOSMALL; \ 521 522 p += printed 522 523 -
pjproject/trunk/pjsip/src/pjsip-simple/errno.c
r3553 r4613 111 111 "Unknown pjsip-simple error %d", 112 112 statcode); 113 113 if (errstr.slen < 1 || errstr.slen >= (pj_ssize_t)bufsize) 114 errstr.slen = bufsize - 1; 114 115 return errstr; 115 116 } -
pjproject/trunk/pjsip/src/pjsip-ua/sip_100rel.c
r4208 r4613 345 345 (int)tsx->method.name.slen, 346 346 tsx->method.name.ptr); 347 if (rack.slen < 1 || rack.slen >= (int)sizeof(rack_buf)) { 348 return PJ_ETOOSMALL; 349 } 347 350 rack_hdr = pjsip_generic_string_hdr_create(tdata->pool, &RACK, &rack); 348 351 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*) rack_hdr); -
pjproject/trunk/pjsip/src/pjsip/sip_errno.c
r3553 r4613 205 205 "Unknown pjsip error %d", 206 206 statcode); 207 207 if (errstr.slen < 1 || errstr.slen >= (pj_ssize_t)bufsize) 208 errstr.slen = bufsize - 1; 208 209 return errstr; 209 210 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r4592 r4613 1750 1750 (int)acc->cfg.contact_params.slen, 1751 1751 acc->cfg.contact_params.ptr); 1752 if (len < 1 ) {1752 if (len < 1 || len >= PJSIP_MAX_URL_SIZE) { 1753 1753 PJ_LOG(1,(THIS_FILE, "URI too long")); 1754 1754 pj_pool_release(pool); … … 3102 3102 (int)acc->cfg.contact_params.slen, 3103 3103 acc->cfg.contact_params.ptr); 3104 3104 if (contact->slen < 1 || contact->slen >= (int)PJSIP_MAX_URL_SIZE) 3105 return PJ_ETOOSMALL; 3105 3106 return PJ_SUCCESS; 3106 3107 } … … 3272 3273 (int)acc->cfg.contact_params.slen, 3273 3274 acc->cfg.contact_params.ptr); 3275 if (contact->slen < 1 || contact->slen >= (int)PJSIP_MAX_URL_SIZE) 3276 return PJ_ETOOSMALL; 3274 3277 3275 3278 return PJ_SUCCESS; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_aud.c
r4537 r4613 1760 1760 if (param->base.clock_rate != pjsua_var.media_cfg.clock_rate) { 1761 1761 char tmp_buf[128]; 1762 int tmp_buf_len = sizeof(tmp_buf);1763 1764 tmp_buf_len = pj_ansi_snprintf(tmp_buf, sizeof(tmp_buf) -1,1762 int tmp_buf_len; 1763 1764 tmp_buf_len = pj_ansi_snprintf(tmp_buf, sizeof(tmp_buf), 1765 1765 "%s (%dKHz)", 1766 1766 rec_info.name, 1767 1767 param->base.clock_rate/1000); 1768 if (tmp_buf_len < 1 || tmp_buf_len >= (int)sizeof(tmp_buf)) 1769 tmp_buf_len = sizeof(tmp_buf) - 1; 1768 1770 pj_strset(&tmp, tmp_buf, tmp_buf_len); 1769 1771 pjmedia_conf_set_port0_name(pjsua_var.mconf, &tmp); -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_dump.c
r4537 r4613 129 129 ); 130 130 131 if (len < 1 || len > end-p) {131 if (len < 1 || len >= end-p) { 132 132 *p = '\0'; 133 133 return (unsigned)(p-buf); … … 187 187 ); 188 188 189 if (len < 1 || len > end-p) {189 if (len < 1 || len >= end-p) { 190 190 *p = '\0'; 191 191 return (unsigned)(p-buf); … … 202 202 pj_math_stat_get_stddev(&stat->rtt) / 1000.0 203 203 ); 204 if (len < 1 || len > end-p) {204 if (len < 1 || len >= end-p) { 205 205 *p = '\0'; 206 206 return (unsigned)(p-buf); … … 260 260 "%s #%d %s deactivated\n", 261 261 indent, i, media_type_str); 262 if (len < 1 || len > end-p) {262 if (len < 1 || len >= end-p) { 263 263 *p = '\0'; 264 264 return; … … 364 364 dir_str, 365 365 rem_addr); 366 if (len < 1 || len > end-p) {366 if (len < 1 || len >= end-p) { 367 367 *p = '\0'; 368 368 return; … … 471 471 472 472 # define VALIDATE_PRINT_BUF() \ 473 if (len < 1 || len > end-p) { *p = '\0'; return; } \473 if (len < 1 || len >= end-p) { *p = '\0'; return; } \ 474 474 p += len; *p++ = '\n'; *p = '\0' 475 475
Note: See TracChangeset
for help on using the changeset viewer.