[misc] Make it easier to debug overflow

This commit is contained in:
ejurgensen 2024-04-06 22:02:15 +02:00
parent 1c17231b9e
commit 9ae0097b31
1 changed files with 12 additions and 6 deletions

View File

@ -480,6 +480,12 @@ net_is_http_or_https(const char *url)
/* ----------------------- Conversion/hashing/sanitizers -------------------- */
static void
overflow(const char *str)
{
DPRINTF(E_DBG, L_MISC, "Integer value too large (%s)\n", str);
}
int
safe_atoi32(const char *str, int32_t *val)
{
@ -510,7 +516,7 @@ safe_atoi32(const char *str, int32_t *val)
if (intval > INT32_MAX)
{
DPRINTF(E_DBG, L_MISC, "Integer value too large (%s)\n", str);
overflow(str);
return -1;
}
@ -549,7 +555,7 @@ safe_atou32(const char *str, uint32_t *val)
if (intval > UINT32_MAX)
{
DPRINTF(E_DBG, L_MISC, "Integer value too large (%s)\n", str);
overflow(str);
return -1;
}
@ -588,7 +594,7 @@ safe_hextou32(const char *str, uint32_t *val)
if (intval > UINT32_MAX)
{
DPRINTF(E_DBG, L_MISC, "Integer value too large (%s)\n", str);
overflow(str);
return -1;
}
@ -627,7 +633,7 @@ safe_atoi64(const char *str, int64_t *val)
if (intval > INT64_MAX)
{
DPRINTF(E_DBG, L_MISC, "Integer value too large (%s)\n", str);
overflow(str);
return -1;
}
@ -668,7 +674,7 @@ safe_atou64(const char *str, uint64_t *val)
if (intval > UINT64_MAX)
{
DPRINTF(E_DBG, L_MISC, "Integer value too large (%s)\n", str);
overflow(str);
return -1;
}
@ -707,7 +713,7 @@ safe_hextou64(const char *str, uint64_t *val)
if (intval > UINT64_MAX)
{
DPRINTF(E_DBG, L_MISC, "Integer value too large (%s)\n", str);
overflow(str);
return -1;
}