res_pjproject: Fix DTLS client check failing on some platforms

Certain platforms (mainly BSD derivatives) have an additional length
field in `sockaddr_in6` and `sockaddr_in`.
`ast_sockaddr_from_pj_sockaddr()` does not take this field into account
when copying over values from the `pj_sockaddr` into the `ast_sockaddr`.
The resulting `ast_sockaddr` will have an uninitialized value for
`sin6_len`/`sin_len` while the other `ast_sockaddr` (not converted from
a `pj_sockaddr`) to check against in `ast_sockaddr_pj_sockaddr_cmp()`
has the correct length value set.

This has the effect that `ast_sockaddr_cmp()` will always indicate
an address mismatch, because it does a bitwise comparison, and all DTLS
packets are dropped even if addresses and ports match.

`ast_sockaddr_from_pj_sockaddr()` now checks whether the length fields
are available on the current platform and sets the values accordingly.

Resolves: #505
(cherry picked from commit c251afadb9)
This commit is contained in:
Albrecht Oster
2025-04-10 23:54:00 +02:00
committed by Asterisk Development Team
parent 230f15e40d
commit a2020fd04b
4 changed files with 32 additions and 0 deletions

19
configure vendored
View File

@@ -28233,6 +28233,25 @@ printf "%s\n" "#define HAVE_STRUCT_STAT_ST_MTIMESPEC 1" >>confdefs.h
stat_nsec_found=yes
fi
ac_fn_c_check_member "$LINENO" "struct sockaddr_in6" "sin6_len" "ac_cv_member_struct_sockaddr_in6_sin6_len" "#include <netinet/in.h>
"
if test "x$ac_cv_member_struct_sockaddr_in6_sin6_len" = xyes
then :
printf "%s\n" "#define HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN 1" >>confdefs.h
fi
ac_fn_c_check_member "$LINENO" "struct sockaddr_in" "sin_len" "ac_cv_member_struct_sockaddr_in_sin_len" "#include <netinet/in.h>
"
if test "x$ac_cv_member_struct_sockaddr_in_sin_len" = xyes
then :
printf "%s\n" "#define HAVE_STRUCT_SOCKADDR_IN_SIN_LEN 1" >>confdefs.h
fi
if test "${stat_nsec_found}" != yes; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Cannot determine nanosecond field of struct stat" >&5