[PATCH 5/6] util: Handle NULL pointers in l_safe_ato* functions
Denis Kenzior <[email protected]> Fri, 23 Aug 2024 11:15:49 -0500
| Newsgroups | dev.linux.lists.ell |
|---|---|
| Message-ID | <[email protected]> |
---
ell/util.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/ell/util.c b/ell/util.c
index 45ec6c8110bc..f474098c082b 100644
--- a/ell/util.c
+++ b/ell/util.c
@@ -760,6 +760,9 @@ static int safe_atou(const char *s, int base, unsigned int *out_u)
LIB_EXPORT int l_safe_atou32(const char *s, uint32_t *out_u)
{
+ if (unlikely(!s))
+ return -EINVAL;
+
if (!l_ascii_isdigit(s[0]))
return -EINVAL;
@@ -808,6 +811,9 @@ LIB_EXPORT int l_safe_atox16(const char *s, uint16_t *out_x)
LIB_EXPORT int l_safe_atox32(const char *s, uint32_t *out_x)
{
+ if (unlikely(!s))
+ return -EINVAL;
+
if (!l_ascii_isxdigit(s[0]))
return -EINVAL;
--
2.45.2