Changeset 5224


Ignore:
Timestamp:
Dec 30, 2015 11:52:54 PM (5 years ago)
Author:
ming
Message:

Re #1882 (misc): Add checking before calling pj_strncpy(), to make it more robust and consistent with the other two checks below.
Note that without the check, it should be safe, but the buffer could point to one byte after the buffer, even though the string length is zero.

Thanks to Dusan Klinec for the proposed patch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c

    r4713 r5224  
    250250 
    251251    /* contact */ 
    252     info->contact.ptr = info->buf_ + total; 
    253     pj_strncpy(&info->contact, &buddy->contact, sizeof(info->buf_)-total); 
    254     total += info->contact.slen; 
     252    if (total < sizeof(info->buf_)) { 
     253        info->contact.ptr = info->buf_ + total; 
     254        pj_strncpy(&info->contact, &buddy->contact, sizeof(info->buf_) - total); 
     255        total += info->contact.slen; 
     256    } else { 
     257        info->contact = pj_str(""); 
     258    } 
    255259 
    256260    /* Presence status */ 
Note: See TracChangeset for help on using the changeset viewer.