diff options
| author | Dr. David Alan Gilbert <[email protected]> | 2022-10-29 01:46:04 +0000 |
|---|---|---|
| committer | Jakub Kicinski <[email protected]> | 2022-11-02 04:14:39 +0000 |
| commit | 44827016be44c6b2634a92ebbdb3d95610ff5268 (patch) | |
| tree | 1d383322e95c17805f57b861b985ad983709f60c /net/core/utils.c | |
| parent | Merge branch 'inet-add-drop-monitor-support' (diff) | |
| download | kernel-44827016be44c6b2634a92ebbdb3d95610ff5268.tar.gz kernel-44827016be44c6b2634a92ebbdb3d95610ff5268.zip | |
net: core: inet[46]_pton strlen len types
inet[46]_pton check the input length against
a sane length limit (INET[6]_ADDRSTRLEN), but
the strlen value gets truncated due to being stored in an int,
so there's a theoretical potential for a >4G string to pass
the limit test.
Use size_t since that's what strlen actually returns.
I've had a hunt for callers that could hit this, but
I've not managed to find anything that doesn't get checked with
some other limit first; but it's possible that I've missed
something in the depth of the storage target paths.
Signed-off-by: Dr. David Alan Gilbert <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Diffstat (limited to 'net/core/utils.c')
| -rw-r--r-- | net/core/utils.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/core/utils.c b/net/core/utils.c index 938495bc1d34..c994e95172ac 100644 --- a/net/core/utils.c +++ b/net/core/utils.c @@ -302,7 +302,7 @@ static int inet4_pton(const char *src, u16 port_num, struct sockaddr_storage *addr) { struct sockaddr_in *addr4 = (struct sockaddr_in *)addr; - int srclen = strlen(src); + size_t srclen = strlen(src); if (srclen > INET_ADDRSTRLEN) return -EINVAL; @@ -322,7 +322,7 @@ static int inet6_pton(struct net *net, const char *src, u16 port_num, { struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr; const char *scope_delim; - int srclen = strlen(src); + size_t srclen = strlen(src); if (srclen > INET6_ADDRSTRLEN) return -EINVAL; |
