libc: Typecast to avoid overflow in inet_addr for AVR
Signed-off-by: Brennan Ashton <bashton@brennanashton.com>
This commit is contained in:
parent
470624fa78
commit
871613f271
@ -102,7 +102,7 @@ in_addr_t inet_addr(FAR const char *cp)
|
||||
{
|
||||
if ((a < 0x100) && (b < 0x1000000))
|
||||
{
|
||||
result = (a << 24) | b;
|
||||
result = (((uint32_t) a) << 24) | b;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -111,7 +111,7 @@ in_addr_t inet_addr(FAR const char *cp)
|
||||
{
|
||||
if ((a < 0x100) && (b < 0x100) && (c < 0x10000))
|
||||
{
|
||||
result = (a << 24) | (b << 16) | c;
|
||||
result = (((uint32_t) a) << 24) | (((uint32_t) b) << 16) | c;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -120,7 +120,8 @@ in_addr_t inet_addr(FAR const char *cp)
|
||||
{
|
||||
if ((a < 0x100) && (b < 0x100) && (c < 0x100) && (d < 0x100))
|
||||
{
|
||||
result = (a << 24) | (b << 16) | (c << 8) | d;
|
||||
result = (((uint32_t) a) << 24) | (((uint32_t) b) << 16) |
|
||||
(((uint32_t) c) << 8) | d;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user