|
@@ -73,18 +73,23 @@
|
|
|
inline int db_str2int(const char* _s, int* _v)
|
|
|
{
|
|
|
long tmp;
|
|
|
+ char* p = NULL;
|
|
|
|
|
|
if (!_s || !_v) {
|
|
|
LM_ERR("Invalid parameter value\n");
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- tmp = strtoul(_s, 0, 10);
|
|
|
+ tmp = strtoul(_s, &p, 10);
|
|
|
if ((tmp == ULONG_MAX && errno == ERANGE) ||
|
|
|
(tmp < INT_MIN) || (tmp > UINT_MAX)) {
|
|
|
LM_ERR("Value out of range\n");
|
|
|
return -1;
|
|
|
}
|
|
|
+ if (p && *p != '\0') {
|
|
|
+ LM_ERR("Unexpected characters: [%s]\n", p);
|
|
|
+ return -2;
|
|
|
+ }
|
|
|
|
|
|
*_v = (int)tmp;
|
|
|
return 0;
|
|
@@ -94,17 +99,22 @@ inline int db_str2int(const char* _s, int* _v)
|
|
|
inline int db_str2longlong(const char* _s, long long * _v)
|
|
|
{
|
|
|
long long tmp;
|
|
|
+ char* p = NULL;
|
|
|
|
|
|
if (!_s || !_v) {
|
|
|
LM_ERR("Invalid parameter value\n");
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- tmp = strtoll(_s, 0, 10);
|
|
|
+ tmp = strtoll(_s, &p, 10);
|
|
|
if (errno == ERANGE) {
|
|
|
LM_ERR("Value out of range\n");
|
|
|
return -1;
|
|
|
}
|
|
|
+ if (p && *p != '\0') {
|
|
|
+ LM_ERR("Unexpected characters: [%s]\n", p);
|
|
|
+ return -2;
|
|
|
+ }
|
|
|
|
|
|
*_v = tmp;
|
|
|
return 0;
|