diff options
Diffstat (limited to 'inet')
| -rw-r--r-- | inet/bits/inet-fortified-decl.h | 7 | ||||
| -rw-r--r-- | inet/bits/inet-fortified.h | 20 |
2 files changed, 27 insertions, 0 deletions
diff --git a/inet/bits/inet-fortified-decl.h b/inet/bits/inet-fortified-decl.h index 23e3cf4b22..748a119f14 100644 --- a/inet/bits/inet-fortified-decl.h +++ b/inet/bits/inet-fortified-decl.h @@ -32,4 +32,11 @@ extern const char *__REDIRECT_NTH (__inet_ntop_chk_warn, __warnattr ("inet_ntop called with bigger length than " "size of destination buffer"); +extern int __inet_pton_chk (int, const char *, void *, size_t); + +extern int __REDIRECT_FORTIFY_NTH (__inet_pton_alias, + (int, const char *, void *), inet_pton); +extern int __REDIRECT_NTH (__inet_pton_chk_warn, + (int, const char *, void *, size_t), __inet_pton_chk) + __warnattr ("inet_pton called with a destination buffer size too small"); #endif /* bits/inet-fortified-decl.h. */ diff --git a/inet/bits/inet-fortified.h b/inet/bits/inet-fortified.h index 4f6bc34b0f..6738221a54 100644 --- a/inet/bits/inet-fortified.h +++ b/inet/bits/inet-fortified.h @@ -38,4 +38,24 @@ __NTH (inet_ntop (int __af, __af, __src, __dst, __dst_size); }; +__fortify_function __attribute_overloadable__ int +__NTH (inet_pton (int __af, + const char *__restrict __src, + __fortify_clang_overload_arg (void *, __restrict, __dst))) + __fortify_clang_warning_only_if_bos0_lt + (4, __dst, "inet_pton called with destination buffer size less than 4") +{ + size_t sz = 0; + if (__af == AF_INET) + sz = sizeof (struct in_addr); + else if (__af == AF_INET6) + sz = sizeof (struct in6_addr); + else + return __inet_pton_alias (__af, __src, __dst); + + return __glibc_fortify (inet_pton, sz, sizeof (char), + __glibc_objsize (__dst), + __af, __src, __dst); +}; + #endif /* bits/inet-fortified.h. */ |
