gets_chk \
getwd_chk \
inet_ntop_chk \
+ inet_pton_chk \
longjmp_chk \
mbsnrtowcs_chk \
mbsrtowcs_chk \
}
GLIBC_2.42 {
__inet_ntop_chk;
+ __inet_pton_chk;
}
GLIBC_PRIVATE {
__fortify_fail;
--- /dev/null
+/* Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <arpa/inet.h>
+#include <stdio.h>
+
+int
+__inet_pton_chk (int af, const char *src, void *dst, size_t dst_size)
+{
+ if ((af == AF_INET && dst_size < 4)
+ || (af == AF_INET6 && dst_size < 16))
+ __chk_fail ();
+
+ return __inet_pton (af, src, dst);
+}
+libc_hidden_def (__inet_pton_chk)
CHK_FAIL_END
#endif
+ const char *ipv4str = "127.0.0.1";
+ const char *ipv6str = "::1";
+
+ if (inet_pton (AF_INET, ipv4str, (void *) &addr) != 1)
+ FAIL ();
+ if (inet_pton (AF_INET6, ipv6str, (void *) &addr6) != 1)
+ FAIL ();
+
+#if __USE_FORTIFY_LEVEL >= 1
+ char smallbuf[2];
+
+ CHK_FAIL_START
+ inet_pton (AF_INET, ipv4str, (void *) smallbuf);
+ CHK_FAIL_END
+
+ CHK_FAIL_START
+ inet_pton (AF_INET6, ipv6str, (void *) smallbuf);
+ CHK_FAIL_END
+
+ CHK_FAIL_START
+ inet_pton (AF_INET6, ipv6str, (void *) &addr);
+ CHK_FAIL_END
+#endif
+
return ret;
}
libc_hidden_proto (inet_pton)
extern __typeof (inet_pton) __inet_pton;
libc_hidden_proto (__inet_pton)
+libc_hidden_proto (__inet_pton_chk)
+
extern __typeof (inet_makeaddr) __inet_makeaddr;
libc_hidden_proto (__inet_makeaddr)
libc_hidden_proto (inet_netof)
__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. */
__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. */
@item @code{inet_ntop}
+@item @code{inet_pton}
+
@item @code{longjmp}
@item @code{mbsnrtowcs}
GLIBC_2.41 pthread_mutexattr_settype F
GLIBC_2.41 pthread_sigmask F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_barrier_destroy F
GLIBC_2.42 pthread_barrier_init F
GLIBC_2.42 pthread_barrier_wait F
GLIBC_2.41 pthread_mutexattr_settype F
GLIBC_2.41 pthread_sigmask F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_barrier_destroy F
GLIBC_2.42 pthread_barrier_init F
GLIBC_2.42 pthread_barrier_wait F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.41 sched_getattr F
GLIBC_2.41 sched_setattr F
GLIBC_2.42 __inet_ntop_chk F
+GLIBC_2.42 __inet_pton_chk F
GLIBC_2.42 pthread_gettid_np F