Ignore:
Timestamp:
Nov 8, 2017 2:58:18 AM (5 years ago)
Author:
riza
Message:

Closed #2056: Add validity checking for numeric header values.

File:
1 edited

Legend:

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

    r5520 r5682  
    2828#include <pj/types.h> 
    2929#include <pj/compat/string.h> 
    30  
    3130 
    3231PJ_BEGIN_DECL 
     
    637636 
    638637/** 
     638 * Convert string to signed long integer. The conversion will stop as 
     639 * soon as non-digit character is found or all the characters have 
     640 * been processed. 
     641 * 
     642 * @param str   the string. 
     643 * @param value Pointer to a long to receive the value. 
     644 * 
     645 * @return PJ_SUCCESS if successful.  Otherwise: 
     646 *         PJ_ETOOSMALL if the value was an impossibly long negative number. 
     647 *         In this case *value will be set to LONG_MIN. 
     648 *         \n 
     649 *         PJ_ETOOBIG if the value was an impossibly long positive number. 
     650 *         In this case, *value will be set to LONG_MAX. 
     651 *         \n 
     652 *         PJ_EINVAL if the input string was NULL, the value pointer was NULL  
     653 *         or the input string could not be parsed at all such as starting with 
     654 *         a character other than a '+', '-' or not in the '0' - '9' range. 
     655 *         In this case, *value will be left untouched. 
     656 */ 
     657PJ_DECL(pj_status_t) pj_strtol2(const pj_str_t *str, long *value); 
     658 
     659 
     660/** 
    639661 * Convert string to unsigned integer. The conversion will stop as 
    640662 * soon as non-digit character is found or all the characters have 
     
    663685PJ_DECL(unsigned long) pj_strtoul2(const pj_str_t *str, pj_str_t *endptr, 
    664686                                   unsigned base); 
     687 
     688/** 
     689 * Convert string to unsigned long integer. The conversion will stop as 
     690 * soon as non-digit character is found or all the characters have 
     691 * been processed. 
     692 * 
     693 * @param str       The input string. 
     694 * @param value     Pointer to an unsigned long to receive the value. 
     695 * @param base      Number base to use. 
     696 * 
     697 * @return PJ_SUCCESS if successful.  Otherwise: 
     698 *         PJ_ETOOBIG if the value was an impossibly long positive number. 
     699 *         In this case, *value will be set to ULONG_MAX. 
     700 *         \n 
     701 *         PJ_EINVAL if the input string was NULL, the value pointer was NULL  
     702 *         or the input string could not be parsed at all such as starting  
     703 *         with a character outside the base character range.  In this case, 
     704 *         *value will be left untouched. 
     705 */ 
     706PJ_DECL(pj_status_t) pj_strtoul3(const pj_str_t *str, unsigned long *value, 
     707                                 unsigned base); 
    665708 
    666709/** 
     
    787830} 
    788831 
    789  
    790832/** 
    791833 * @} 
Note: See TracChangeset for help on using the changeset viewer.