Changeset 5229


Ignore:
Timestamp:
Dec 31, 2015 5:06:03 AM (8 years ago)
Author:
ming
Message:

Re #1882 (misc): Add assertion checks in pj_strncpy() and pj_strncpy_with_null(). When max is negative, it may go undetected and cause crash since it will be cast to an unsigned when calling pj_memcpy().

Thanks to Dusan Klinec for the suggestion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/include/pj/string_i.h

    r4537 r5229  
    1919 */ 
    2020 
     21#include <pj/assert.h> 
    2122#include <pj/pool.h> 
    2223 
     
    118119                               pj_ssize_t max) 
    119120{ 
     121    pj_assert(max >= 0); 
    120122    if (max > src->slen) max = src->slen; 
    121123    pj_memcpy(dst->ptr, src->ptr, max); 
     
    127129                                         pj_ssize_t max) 
    128130{ 
     131    pj_assert(max > 0); 
     132 
    129133    if (max <= src->slen) 
    130134        max = max-1; 
Note: See TracChangeset for help on using the changeset viewer.