size_t len; \
long long num; \
fr_sbuff_t our_in = FR_SBUFF(in); \
+ buff[0] = '\0'; /* clang scan */ \
len = fr_sbuff_out_bstrncpy(&FR_SBUFF_IN(buff, sizeof(buff)), &our_in, _max_char); \
if (len == 0) { \
if (err) *err = FR_SBUFF_PARSE_ERROR_NOT_FOUND; \
return -1; \
} \
- errno = 0; \
+ errno = 0; /* this is needed as strtoll doesn't reset errno */ \
num = strtoll(buff, &end, _base); \
if (end == buff) { \
if (err) *err = FR_SBUFF_PARSE_ERROR_NOT_FOUND; \
*out = (_type)(_min); \
return -1; \
} else if (no_trailing && (((a_end = in->p + (end - buff)) + 1) < in->end)) { \
- if (isdigit(*a_end) || (((_base > 10) || (_base == 0)) && ((tolower(*a_end) >= 'a') && (tolower(*a_end) <= 'f')))) { \
+ if (isdigit(*a_end) || (((_base > 10) || ((_base == 0) && (len > 2) && (buff[0] == '0') && (buff[1] == 'x'))) && \
+ ((tolower(*a_end) >= 'a') && (tolower(*a_end) <= 'f')))) { \
if (err) *err = FR_SBUFF_PARSE_ERROR_TRAILING; \
*out = (_type)(_max); \
return fr_sbuff_error(&our_in); \
size_t len; \
unsigned long long num; \
fr_sbuff_t our_in = FR_SBUFF(in); \
+ buff[0] = '\0'; /* clang scan */ \
len = fr_sbuff_out_bstrncpy(&FR_SBUFF_IN(buff, sizeof(buff)), &our_in, _max_char); \
if (len == 0) { \
if (err) *err = FR_SBUFF_PARSE_ERROR_NOT_FOUND; \
if (err) *err = FR_SBUFF_PARSE_ERROR_NUM_UNDERFLOW; \
return -1; \
} \
- errno = 0; \
+ errno = 0; /* this is needed as strtoull doesn't reset errno */ \
num = strtoull(buff, &end, _base); \
if (end == buff) { \
if (err) *err = FR_SBUFF_PARSE_ERROR_NOT_FOUND; \
*out = (_type)(_max); \
return -1; \
} else if (no_trailing && (((a_end = in->p + (end - buff)) + 1) < in->end)) { \
- if (isdigit(*a_end) || (((_base > 10) || (_base == 0)) && ((tolower(*a_end) >= 'a') && (tolower(*a_end) <= 'f')))) { \
+ if (isdigit(*a_end) || (((_base > 10) || ((_base == 0) && (len > 2) && (buff[0] == '0') && (buff[1] == 'x'))) && \
+ ((tolower(*a_end) >= 'a') && (tolower(*a_end) <= 'f')))) { \
if (err) *err = FR_SBUFF_PARSE_ERROR_TRAILING; \
*out = (_type)(_max); \
return fr_sbuff_error(&our_in); \
if (err) *err = FR_SBUFF_PARSE_ERROR_NOT_FOUND; \
return -1; \
} \
- errno = 0; \
+ errno = 0; /* this is needed as parsing functions don't reset errno */ \
res = _func(buff, &end); \
if (errno == ERANGE) { \
if (res > 0) { \