Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • dlublink/asterisk
  • bunk/asterisk
  • jasper-guest/asterisk
3 results
Show changes
Commits on Source (10)
Showing
with 2585 additions and 24 deletions
debian/dh_asterisk.1
asterisk (1:16.23.0~dfsg+~cs6.10.20220309-2) unstable; urgency=medium
* update debhelper script dh_asterisk:
+ fix move excess paragraphs from POD section NAME to DESCRIPTION
+ fix reference man page debhelper(7) (not bogus debhelper(1)
+ add POD section COPYRIGHT AND LICENSE
+ simplify POD section SYNOPSIS
+ drop POD sections OPTIONS (superfluous) and NOTES (bogus)
+ fix typo in POD section DESCRIPTION
+ extend POD section DESCRIPTION
to mention dh-sequence-asterisk (inspired by POD of dh_perl_openssl)
* provide virtual package asterisk-abi-* (not asterisk-*),
and have dh_asterisk generate matching package variable
${asterisk:Depends} (not the core less intuitive ${asterisk:ABI})
* generate and install manpage for dh_asterisk;
build-depend on perl
* cherry-pick bugfix patches upstream; unfuzz remaining patches
-- Jonas Smedegaard <dr@jones.dk> Sun, 23 Jan 2022 15:33:47 +0100
asterisk (1:16.23.0~dfsg+~cs6.10.20220309-1) unstable; urgency=medium
* finalize and install debhelper script dh_asterisk;
......
......@@ -3,6 +3,7 @@ addons/mp3/*
codecs/codec_amr.c
codecs/ex_amr.h
debian/build-pjproject/
debian/dh_asterisk.1
doc/core-en_US.xml
include/asterisk/amr.h
utils/poll.c
......
......@@ -66,6 +66,7 @@ Build-Depends:
libvpb-dev [linux-any],
libxml2-dev,
libxslt1-dev,
perl,
portaudio19-dev,
unixodbc-dev,
uuid-dev,
......@@ -88,7 +89,7 @@ Depends:
Pre-Depends:
${misc:Pre-Depends},
Provides:
asterisk-${asterisk:ABI},
asterisk-abi-${asterisk:ABI},
Recommends:
asterisk-moh-opsound-gsm,
asterisk-voicemail | asterisk-voicemail-storage,
......
......@@ -1249,6 +1249,8 @@ Files: BSDmakefile
debian/asterisk-config.preinst
debian/asterisk-dahdi.install
debian/asterisk-dev.install
debian/asterisk-dev.lintian-overrides
debian/asterisk-dev.manpages
debian/asterisk-doc.docs
debian/asterisk-mobile.install
debian/asterisk-modules.install
......@@ -1281,10 +1283,31 @@ Files: BSDmakefile
debian/control
debian/copyright-check
debian/debhelper/asterisk.pm
debian/debhelper/dh_asterisk
debian/dummyprogs/fetch
debian/gbp.conf
debian/not-installed
debian/patches/020211026~a641299.patch
debian/patches/020211101~d8d4ac8.patch
debian/patches/020211108~3162f6d.patch
debian/patches/020211111~01d85e0.patch
debian/patches/020211111~e65f7e5.patch
debian/patches/020211115~a3fcda5.patch
debian/patches/020211117~3c08ce4.patch
debian/patches/020211124~1ac89e0.patch
debian/patches/020211208~ff0b048.patch
debian/patches/020211213~1e7bcc2.patch
debian/patches/020211213~75b9b93.patch
debian/patches/020211214~f2cfce1.patch
debian/patches/020211224~6060b9c.patch
debian/patches/020211227~a363153.patch
debian/patches/020211230~ac9607d.patch
debian/patches/020220104~85881d8.patch
debian/patches/020220104~8c230eb.patch
debian/patches/020220106~2f2af26.patch
debian/patches/020220110~9e975d4.patch
debian/patches/020220111~67a87c0.patch
debian/patches/020220112~96c2a79.patch
debian/patches/020220119~14156f9.patch
debian/patches/1001_multiple_app_voicemail.patch
debian/patches/1002_h323_avoid_linking.patch
debian/patches/1003_h323_segfault_workaround.patch
......@@ -4823,6 +4846,11 @@ Copyright: 2004, Steve Underwood
License: GPL-2+ and/or LGPL
FIXME
Files: debian/debhelper/dh_asterisk
Copyright: 2022, Jonas Smedegaard <dr@jones.dk>
License: GPL-3+
FIXME
Files: autoconf/ax_pthread.m4
Copyright: 2008, Steven G. Johnson <stevenj@alum.mit.edu>
2011, Daniel Richard G. <skunk@iSKUNK.ORG>
......
......@@ -4,17 +4,6 @@
dh_asterisk - Add dependency on the ABI version of Asterisk
When writing a package that builds an Asterisk module and is not built
with Astersk itself (and hence depends on the exact binary version),
add ${asterisk:ABI} to the package's Depends: field in debian control
and run dh_asterisk.
If you use dh, you can run dh_asterisk using:
dh --with asterisk
Otherwise run it in debian/rules after installing the modules.
=cut
use strict;
......@@ -23,22 +12,29 @@ use Debian::Debhelper::Dh_Lib;
=head1 SYNOPSIS
B<dh_asterisk> [S<I<debhelper options>>] [S<B<-V>[I<version>]>] [S<B<--> I<file>>]
B<dh_asterisk> [S<I<debhelper options>>]
=head1 DESCRIPTION
dh_asterisk is a debhelper program that is responsible for correctly
setting the dependency on asterisk-I<asterisk-ABI-version> for a package.
setting the dependency on asterisk-abi-I<asterisk-ABI-version> for a package.
=head1 OPTIONS
When writing a package that builds an Asterisk module and is not built
with Asterisk itself (and hence depends on the exact binary version),
add ${asterisk:Depends} to the package's Depends: field in debian control
and run dh_asterisk.
A debhelper addon is also provided.
This makes it possible to just use
No special options of its own. Use standard debhelper options.
#!/usr/bin/make -f
%:
dh $@ --with asterisk
=head1 NOTES
for F<debian/rules>.
Note that this command is not idempotent. L<dh_prep(1)> should be called
between invocations of this command. Otherwise, it may cause multiple
instances of the same text to be added to maintainer scripts.
Alternatively, you can just build-depend on B<dh-sequence-asterisk>
and omit the C<--with asterisk> part.
=cut
......@@ -66,12 +62,12 @@ else {
}
foreach my $package (@{$dh{DOPACKAGES}}) {
addsubstvar($package, "asterisk:ABI", $abi);
addsubstvar($package, "asterisk:Depends", "asterisk-abi-$abi");
}
=head1 SEE ALSO
L<debhelper(1)>
L<debhelper(7)>
This program is part of the Debian Asterisk package.
......@@ -83,4 +79,12 @@ Tzafrir Cohen <tzafrir@debian.org>
Jonas Smedegaard <dr@jones.dk>
=cut
=head1 COPYRIGHT AND LICENSE
Copyright 2022, Jonas Smedegaard <dr@jones.dk>
This packaging is free software;
you can redistribute it and/or modify it
under the terms of the GNU General Public License
as published by the Free Software Foundation;
either version 3, or (at your option) any later version.
Description: res_rtp_asterisk: Addressing possible rtp range issues
Adding 1 to rtpstart
if it is deteremined that rtpstart was configured
to be an odd value.
Also adding a loop counter
to prevent a possible infinite loop
when looking for a free port.
Author: Mike Bradeen <mbradeen@sangoma.com>
Source: https://github.com/asterisk/asterisk/commit/a641299
Bug: https://issues.asterisk.org/jira/browse/ASTERISK-27406
Last-Update: 2022-01-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -3847,7 +3847,7 @@
static int rtp_allocate_transport(struct ast_rtp_instance *instance, struct ast_rtp *rtp)
{
- int x, startplace;
+ int x, startplace, i, maxloops;
rtp->strict_rtp_state = (strictrtp ? STRICT_RTP_CLOSED : STRICT_RTP_OPEN);
@@ -3861,11 +3861,14 @@
}
/* Now actually find a free RTP port to use */
- x = (rtpend == rtpstart) ? rtpstart : (ast_random() % (rtpend - rtpstart)) + rtpstart;
+ x = (ast_random() % (rtpend - rtpstart)) + rtpstart;
x = x & ~1;
startplace = x;
- for (;;) {
+ /* Protection against infinite loops in the case there is a potential case where the loop is not broken such as an odd
+ start port sneaking in (even though this condition is checked at load.) */
+ maxloops = rtpend - rtpstart;
+ for (i = 0; i <= maxloops; i++) {
ast_sockaddr_set_port(&rtp->bind_address, x);
/* Try to bind, this will tell us whether the port is available or not */
if (!ast_bind(rtp->s, &rtp->bind_address)) {
@@ -9707,6 +9710,13 @@
ast_config_destroy(cfg);
+ /* Choosing an odd start port casues issues (like a potential infinite loop) and as odd parts are not
+ chosen anyway, we are going to round up and issue a warning */
+ if (rtpstart & 1) {
+ rtpstart++;
+ ast_log(LOG_WARNING, "Odd start value for RTP port in rtp.conf, rounding up to %d\n", rtpstart);
+ }
+
if (rtpstart >= rtpend) {
ast_log(LOG_WARNING, "Unreasonable values for RTP start/end port in rtp.conf\n");
rtpstart = DEFAULT_RTP_START;
Description: test_time.c: Tolerate DST transitions
When test_timezone_watch runs very near a DST transition,
two time zones
that would otherwise be expected to report the same time
can differ because of the DST transition.
.
Instead of having the test fail when this happens,
report the times, time zones, and dst flags.
Author: Josh Soref <jsoref@gmail.com>
Source: https://github.com/asterisk/asterisk/commit/d8d4ac8
Bug: https://issues.asterisk.org/jira/browse/ASTERISK-29722
Last-Update: 2022-01-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/tests/test_time.c
+++ b/tests/test_time.c
@@ -91,8 +91,12 @@
ast_localtime(&tv, &atm[i], tzfile);
if (i != 0) {
if (atm[i].tm_hour == atm[i - 1].tm_hour) {
- res = AST_TEST_FAIL;
- ast_test_status_update(test, "Failed %s test: %d(%s) = %d(%s)\n", type == 0 ? "deletion" : "symlink", atm[i].tm_hour, zones[i], atm[i-1].tm_hour, zones[i-1]);
+ if (atm[i].tm_isdst == atm[i - 1].tm_isdst) {
+ res = AST_TEST_FAIL;
+ ast_test_status_update(test, "Failed %s test: %d(%s) = %d(%s)\n", type == 0 ? "deletion" : "symlink", atm[i].tm_hour, zones[i], atm[i-1].tm_hour, zones[i-1]);
+ } else {
+ ast_log(LOG_WARNING, "DST transition during %s test: %d(%s/%d) != %d(%s/%d)\n", type == 0 ? "deletion" : "symlink", atm[i].tm_hour, zones[i], atm[i].tm_isdst, atm[i-1].tm_hour, zones[i-1], atm[i-1].tm_isdst);
+ }
}
}
Description: res_fax_spandsp: Add spandsp 3.0.0+ compatibility
Newer versions of spandsp did refactoring of code
to add new features like color FAXing.
This refactoring broke backwards compatibility.
Add support for the new version
while retaining support for 0.0.6.
Author: Dustin Marquess <jailbird@fdf.net>
Source: https://github.com/asterisk/asterisk/commit/3162f6d
Bug: https://issues.asterisk.org/jira/browse/ASTERISK-29729
Last-Update: 2022-01-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- /dev/null
+++ b/doc/CHANGES-staging/res_fax_spandsp.txt
@@ -0,0 +1,3 @@
+Subject: res_fax_spandsp
+
+Adds support for spandsp 3.0.0.
--- a/res/res_fax_spandsp.c
+++ b/res/res_fax_spandsp.c
@@ -167,10 +167,17 @@
static int spandsp_v21_new(struct spandsp_pvt *p);
static void session_destroy(struct spandsp_pvt *p);
static int t38_tx_packet_handler(t38_core_state_t *t38_core_state, void *data, const uint8_t *buf, int len, int count);
-static void t30_phase_e_handler(t30_state_t *t30_state, void *data, int completion_code);
-static void spandsp_log(int level, const char *msg);
static int update_stats(struct spandsp_pvt *p, int completion_code);
static int spandsp_modems(struct ast_fax_session_details *details);
+#if SPANDSP_RELEASE_DATE >= 20120902
+/* for spandsp shaphots 3.0.0 and higher */
+static void t30_phase_e_handler(void *data, int completion_code);
+static void spandsp_log(void *user_data, int level, const char *msg);
+#else
+/* for spandsp release 0.0.6 */
+static void t30_phase_e_handler(t30_state_t *t30_state, void *data, int completion_code);
+static void spandsp_log(int level, const char *msg);
+#endif
static void set_logging(logging_state_t *state, struct ast_fax_session_details *details);
static void set_local_info(t30_state_t *t30_state, struct ast_fax_session_details *details);
@@ -375,13 +382,23 @@
* This function pulls stats from the spandsp stack and stores them for res_fax
* to use later.
*/
+#if SPANDSP_RELEASE_DATE >= 20120902
+/* for spandsp shaphots 3.0.0 and higher */
+static void t30_phase_e_handler(void *data, int completion_code)
+#else
+/* for spandsp release 0.0.6 */
static void t30_phase_e_handler(t30_state_t *t30_state, void *data, int completion_code)
+#endif
{
struct ast_fax_session *s = data;
struct spandsp_pvt *p = s->tech_pvt;
char headerinfo[T30_MAX_PAGE_HEADER_INFO + 1];
const char *c;
t30_stats_t stats;
+#if SPANDSP_RELEASE_DATE >= 20120902
+ /* for spandsp shaphots 3.0.0 and higher */
+ t30_state_t *t30_state = p->t30_state;
+#endif
ast_debug(5, "FAX session '%u' entering phase E\n", s->id);
@@ -430,7 +447,13 @@
*
* \note This function is a callback function called by spandsp.
*/
+#if SPANDSP_RELEASE_DATE >= 20120902
+/* for spandsp shaphots 3.0.0 and higher */
+static void spandsp_log(void *user_data, int level, const char *msg)
+#else
+/* for spandsp release 0.0.6 */
static void spandsp_log(int level, const char *msg)
+#endif
{
if (level == SPAN_LOG_ERROR) {
ast_log(LOG_ERROR, "%s", msg);
@@ -449,7 +472,13 @@
level = SPAN_LOG_DEBUG_3;
}
+#if SPANDSP_RELEASE_DATE >= 20120902
+ /* for spandsp shaphots 3.0.0 and higher */
+ span_log_set_message_handler(state, spandsp_log, NULL);
+#else
+ /* for spandsp release 0.0.6 */
span_log_set_message_handler(state, spandsp_log);
+#endif
span_log_set_level(state, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | level);
}
@@ -479,7 +508,13 @@
static void set_ecm(t30_state_t *t30_state, struct ast_fax_session_details *details)
{
t30_set_ecm_capability(t30_state, details->option.ecm);
+#if SPANDSP_RELEASE_DATE >= 20120902
+ /* for spandsp shaphots 3.0.0 and higher */
+ t30_set_supported_compressions(t30_state, T4_COMPRESSION_T4_1D | T4_COMPRESSION_T4_2D | T4_COMPRESSION_T6);
+#else
+ /* for spandsp release 0.0.6 */
t30_set_supported_compressions(t30_state, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION);
+#endif
}
static int spandsp_v21_new(struct spandsp_pvt *p)
@@ -1256,7 +1291,13 @@
}
/* prevent logging to stderr */
+#if SPANDSP_RELEASE_DATE >= 20120902
+ /* for spandsp shaphots 3.0.0 and higher */
+ span_set_message_handler(NULL, NULL);
+#else
+ /* for spandsp release 0.0.6 */
span_set_message_handler(NULL);
+#endif
return AST_MODULE_LOAD_SUCCESS;
}
Description: include: Remove unimplemented HMAC declarations
Remove the HMAC declarations from the includes.
They are not implemented nor used anywhere,
and their presence breaks the build on NetBSD
that delivers an incompatible hmac() function in <stdlib.h>.
Author: Michał Górny <mgorny@NetBSD.org>
Source: https://github.com/asterisk/asterisk/commit/01d85e0
Bug: https://issues.asterisk.org/jira/browse/ASTERISK-29818
Last-Update: 2022-01-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/include/asterisk/sha1.h
+++ b/include/asterisk/sha1.h
@@ -294,63 +294,6 @@
extern int USHAHashSizeBits(enum SHAversion whichSha);
extern const char *USHAHashName(enum SHAversion whichSha);
-/*
- * HMAC Keyed-Hashing for Message Authentication, RFC 2104,
- * for all SHAs.
- * This interface allows a fixed-length text input to be used.
- */
-extern int hmac(SHAversion whichSha, /* which SHA algorithm to use */
- const unsigned char *text, /* pointer to data stream */
- int text_len, /* length of data stream */
- const unsigned char *key, /* pointer to authentication key */
- int key_len, /* length of authentication key */
- uint8_t digest[USHAMaxHashSize]); /* caller digest to fill in */
-
-/*
- * HMAC Keyed-Hashing for Message Authentication, RFC 2104,
- * for all SHAs.
- * This interface allows any length of text input to be used.
- */
-extern int hmacReset(HMACContext *context, enum SHAversion whichSha,
- const unsigned char *key, int key_len);
-extern int hmacInput(HMACContext *context, const unsigned char *text,
- int text_len);
-extern int hmacFinalBits(HMACContext *context, uint8_t bits,
- unsigned int bit_count);
-extern int hmacResult(HMACContext *context,
- uint8_t digest[USHAMaxHashSize]);
-
-/*
- * HKDF HMAC-based Extract-and-Expand Key Derivation Function,
- * RFC 5869, for all SHAs.
- */
-extern int hkdf(SHAversion whichSha, const unsigned char *salt,
- int salt_len, const unsigned char *ikm, int ikm_len,
- const unsigned char *info, int info_len,
- uint8_t okm[ ], int okm_len);
-extern int hkdfExtract(SHAversion whichSha, const unsigned char *salt,
- int salt_len, const unsigned char *ikm,
- int ikm_len, uint8_t prk[USHAMaxHashSize]);
-extern int hkdfExpand(SHAversion whichSha, const uint8_t prk[ ],
- int prk_len, const unsigned char *info,
- int info_len, uint8_t okm[ ], int okm_len);
-
-/*
- * HKDF HMAC-based Extract-and-Expand Key Derivation Function,
- * RFC 5869, for all SHAs.
- * This interface allows any length of text input to be used.
- */
-extern int hkdfReset(HKDFContext *context, enum SHAversion whichSha,
- const unsigned char *salt, int salt_len);
-extern int hkdfInput(HKDFContext *context, const unsigned char *ikm,
- int ikm_len);
-extern int hkdfFinalBits(HKDFContext *context, uint8_t ikm_bits,
- unsigned int ikm_bit_count);
-extern int hkdfResult(HKDFContext *context,
- uint8_t prk[USHAMaxHashSize],
- const unsigned char *info, int info_len,
- uint8_t okm[USHAMaxHashSize], int okm_len);
-
/************************ sha-private.h ************************/
/***************** See RFC 6234 for details. *******************/
/*
Description: BuildSystem: Fix misdetection of gethostbyname_r() on NetBSD
Fix the configure script
not to detect the presence of gethostbyname_r() on NetBSD incorrectly.
NetBSD includes it as an internal libc symbol
that is not exposed in system headers
and that is incompatible with other implementations.
In order to avoid misdetecting it,
perform the symbol check
only if the declaration is found in the public header first.
Author: Michał Górny <mgorny@NetBSD.org>
Source: https://github.com/asterisk/asterisk/commit/e65f7e5
Bug: https://issues.asterisk.org/jira/browse/ASTERISK-29817
Last-Update: 2022-01-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/configure
+++ b/configure
@@ -2912,6 +2912,52 @@
} # ac_fn_c_check_member
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ as_decl_name=`echo $2|sed 's/ *(.*//'`
+ as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+ (void) $as_decl_use;
+#else
+ (void) $as_decl_name;
+#endif
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
+
# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
# --------------------------------------------
# Tries to find the compile-time value of EXPR in a program that includes
@@ -17556,8 +17602,30 @@
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
-# some systems already have gethostbyname_r so we don't need to build ours in main/utils.c
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname_r" >&5
+# NetBSD libc ships with an internal-only incompatible symbol gethostbyname_r
+ac_fn_c_check_decl "$LINENO" "gethostbyname_r" "ac_cv_have_decl_gethostbyname_r" "#include <stdlib.h>
+ #include <netdb.h>
+
+"
+if test "x$ac_cv_have_decl_gethostbyname_r" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_GETHOSTBYNAME_R $ac_have_decl
+_ACEOF
+if test $ac_have_decl = 1; then :
+ have_gethostbyname_r_public_declaration=yes
+else
+ have_gethostbyname_r_public_declaration=no
+fi
+
+
+if test "x$have_gethostbyname_r_public_declaration" = "xyes"; then
+ # some systems already have gethostbyname_r so we don't need to build ours in main/utils.c
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname_r" >&5
$as_echo_n "checking for library containing gethostbyname_r... " >&6; }
if ${ac_cv_search_gethostbyname_r+:} false; then :
$as_echo_n "(cached) " >&6
@@ -17614,12 +17682,12 @@
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname_r with 6 arguments" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname_r with 6 arguments" >&5
$as_echo_n "checking for gethostbyname_r with 6 arguments... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdlib.h>
- #include <netdb.h>
+ #include <netdb.h>
int
main ()
{
@@ -17642,12 +17710,12 @@
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname_r with 5 arguments" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname_r with 5 arguments" >&5
$as_echo_n "checking for gethostbyname_r with 5 arguments... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdlib.h>
- #include <netdb.h>
+ #include <netdb.h>
int
main ()
{
@@ -17669,6 +17737,7 @@
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
+fi
ac_fn_c_check_header_mongrel "$LINENO" "byteswap.h" "ac_cv_header_byteswap_h" "$ac_includes_default"
if test "x$ac_cv_header_byteswap_h" = xyes; then :
--- a/configure.ac
+++ b/configure.ac
@@ -948,28 +948,38 @@
AC_MSG_RESULT(no)
)
-# some systems already have gethostbyname_r so we don't need to build ours in main/utils.c
-AC_SEARCH_LIBS(gethostbyname_r, [socket nsl])
-
-AC_MSG_CHECKING(for gethostbyname_r with 6 arguments)
-AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([#include <stdlib.h>
- #include <netdb.h>],
- [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (struct hostent **)NULL, (int *)NULL);])],
- AC_MSG_RESULT(yes)
- AC_DEFINE([HAVE_GETHOSTBYNAME_R_6], 1, [Define to 1 if your system has gethostbyname_r with 6 arguments.]),
- AC_MSG_RESULT(no)
+# NetBSD libc ships with an internal-only incompatible symbol gethostbyname_r
+AC_CHECK_DECLS([gethostbyname_r],
+ [have_gethostbyname_r_public_declaration=yes],
+ [have_gethostbyname_r_public_declaration=no],
+ [#include <stdlib.h>
+ #include <netdb.h>]
)
-AC_MSG_CHECKING(for gethostbyname_r with 5 arguments)
-AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([#include <stdlib.h>
- #include <netdb.h>],
- [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (int *)NULL);])],
- AC_MSG_RESULT(yes)
- AC_DEFINE([HAVE_GETHOSTBYNAME_R_5], 1, [Define to 1 if your system has gethostbyname_r with 5 arguments.]),
- AC_MSG_RESULT(no)
-)
+if test "x$have_gethostbyname_r_public_declaration" = "xyes"; then
+ # some systems already have gethostbyname_r so we don't need to build ours in main/utils.c
+ AC_SEARCH_LIBS(gethostbyname_r, [socket nsl])
+
+ AC_MSG_CHECKING(for gethostbyname_r with 6 arguments)
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([#include <stdlib.h>
+ #include <netdb.h>],
+ [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (struct hostent **)NULL, (int *)NULL);])],
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([HAVE_GETHOSTBYNAME_R_6], 1, [Define to 1 if your system has gethostbyname_r with 6 arguments.]),
+ AC_MSG_RESULT(no)
+ )
+
+ AC_MSG_CHECKING(for gethostbyname_r with 5 arguments)
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([#include <stdlib.h>
+ #include <netdb.h>],
+ [struct hostent *he = gethostbyname_r((const char *)NULL, (struct hostent *)NULL, (char *)NULL, (int)0, (int *)NULL);])],
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([HAVE_GETHOSTBYNAME_R_5], 1, [Define to 1 if your system has gethostbyname_r with 5 arguments.]),
+ AC_MSG_RESULT(no)
+ )
+fi
AC_CHECK_HEADER([byteswap.h], [AC_DEFINE_UNQUOTED([HAVE_BYTESWAP_H], 1, [Define to 1 if byteswap.h macros are available.])])
Description: tcptls.c: refactor client connection to be more robust
The current TCP client connect code, blocks
and does not handle EINTR error case.
.
This patch makes the client socket non-blocking while connecting,
ensures a connect does not immediately fail due to EINTR "errors",
and adds a connect timeout option.
.
The original client start call
sets the new timeout option to "infinite",
thus making sure old, orginal behavior is retained.
Author: Kevin Harwell <kharwell@sangoma.com>
Source: https://github.com/asterisk/asterisk/commit/a3fcda5
Bug: https://issues.asterisk.org/jira/browse/ASTERISK-29746
Last-Update: 2022-01-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/include/asterisk/tcptls.h
+++ b/include/asterisk/tcptls.h
@@ -164,8 +164,30 @@
};
/*!
- * \brief attempts to connect and start tcptls session, on error the tcptls_session's
- * ref count is decremented, fd and file are closed, and NULL is returned.
+ * \brief Attempt to connect and start a tcptls session within the given timeout
+ *
+ * \note On error the tcptls_session's ref count is decremented, fd and file
+ * are closed, and NULL is returned.
+ *
+ * \param tcptls_session The session instance to connect and start
+ * \param timeout How long (in milliseconds) to attempt to connect (-1 equals infinite)
+ *
+ * \return The tcptls_session, or NULL on error
+ */
+struct ast_tcptls_session_instance *ast_tcptls_client_start_timeout(
+ struct ast_tcptls_session_instance *tcptls_session, int timeout);
+
+/*!
+ * \brief Attempt to connect and start a tcptls session
+ *
+ * Blocks until a connection is established, or an error occurs.
+ *
+ * \note On error the tcptls_session's ref count is decremented, fd and file
+ * are closed, and NULL is returned.
+ *
+ * \param tcptls_session The session instance to connect and start
+ *
+ * \return The tcptls_session, or NULL on error
*/
struct ast_tcptls_session_instance *ast_tcptls_client_start(struct ast_tcptls_session_instance *tcptls_session);
--- a/main/tcptls.c
+++ b/main/tcptls.c
@@ -582,20 +582,82 @@
#endif
}
-struct ast_tcptls_session_instance *ast_tcptls_client_start(struct ast_tcptls_session_instance *tcptls_session)
+/*!
+ * \internal
+ * \brief Connect a socket
+ *
+ * Attempt to connect to a given address for up to 'timeout' milliseconds. A negative
+ * timeout value equates to an infinite wait time.
+ *
+ * A -1 is returned on error, and an appropriate errno value is set based on the
+ * type of error.
+ *
+ * \param sockfd The socket file descriptor
+ * \param addr The address to connect to
+ * \param timeout How long, in milliseconds, to attempt to connect
+ *
+ * \return 0 if successfully connected, -1 otherwise
+ */
+static int socket_connect(int sockfd, const struct ast_sockaddr *addr, int timeout)
+{
+ int optval = 0;
+ socklen_t optlen = sizeof(int);
+
+ errno = 0;
+
+ if (ast_connect(sockfd, addr)) {
+ int res;
+
+ /*
+ * A connect failure could mean things are still in progress.
+ * If so wait for it to complete.
+ */
+
+ if (errno != EINPROGRESS) {
+ return -1;
+ }
+
+ while ((res = ast_wait_for_output(sockfd, timeout)) != 1) {
+ if (res == 0) {
+ errno = ETIMEDOUT;
+ return -1;
+ }
+
+ if (errno != EINTR) {
+ return -1;
+ }
+ }
+ }
+
+ /* Check the status to ensure it actually connected successfully */
+ if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &optval, &optlen) < 0) {
+ return -1;
+ }
+
+ if (optval) {
+ errno = optval;
+ return -1;
+ }
+
+ return 0;
+}
+
+struct ast_tcptls_session_instance *ast_tcptls_client_start_timeout(
+ struct ast_tcptls_session_instance *tcptls_session, int timeout)
{
struct ast_tcptls_session_args *desc;
if (!(desc = tcptls_session->parent)) {
- goto client_start_error;
+ ao2_ref(tcptls_session, -1);
+ return NULL;
}
- if (ast_connect(desc->accept_fd, &desc->remote_address)) {
- ast_log(LOG_ERROR, "Unable to connect %s to %s: %s\n",
- desc->name,
- ast_sockaddr_stringify(&desc->remote_address),
- strerror(errno));
- goto client_start_error;
+ if (socket_connect(desc->accept_fd, &desc->remote_address, timeout)) {
+ ast_log(LOG_WARNING, "Unable to connect %s to %s: %s\n", desc->name,
+ ast_sockaddr_stringify(&desc->remote_address), strerror(errno));
+
+ ao2_ref(tcptls_session, -1);
+ return NULL;
}
ast_fd_clear_flags(desc->accept_fd, O_NONBLOCK);
@@ -606,10 +668,11 @@
}
return handle_tcptls_connection(tcptls_session);
+}
-client_start_error:
- ao2_ref(tcptls_session, -1);
- return NULL;
+struct ast_tcptls_session_instance *ast_tcptls_client_start(struct ast_tcptls_session_instance *tcptls_session)
+{
+ return ast_tcptls_client_start_timeout(tcptls_session, -1);
}
struct ast_tcptls_session_instance *ast_tcptls_client_create(struct ast_tcptls_session_args *desc)
@@ -626,7 +689,7 @@
/* If we return early, there is no connection */
ast_sockaddr_setnull(&desc->old_address);
- fd = desc->accept_fd = socket(ast_sockaddr_is_ipv6(&desc->remote_address) ?
+ fd = desc->accept_fd = ast_socket_nonblock(ast_sockaddr_is_ipv6(&desc->remote_address) ?
AF_INET6 : AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (desc->accept_fd < 0) {
ast_log(LOG_ERROR, "Unable to allocate socket for %s: %s\n",
@@ -673,6 +736,7 @@
/* Set current info */
ast_sockaddr_copy(&desc->old_address, &desc->remote_address);
+
return tcptls_session;
error:
This diff is collapsed.
Description: chan_sip: Fix crash when accessing RURI before initiating outgoing call
Attempting to access ${CHANNEL(ruri)} in a pre-dial handler
before initiating an outgoing call will cause Asterisk to crash.
This is because a null field is accessed,
resulting in an offset from null
and subsequent memory access violation.
.
Since RURI is not guaranteed to exist,
we now check if the base pointer is non-null
before calculating an offset.
Author: Naveen Albert <asterisk@phreaknet.org>
Source: https://github.com/asterisk/asterisk/commit/1ac89e0
Bug: https://issues.asterisk.org/jira/browse/ASTERISK-29772
Last-Update: 2022-01-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/channels/sip/dialplan_functions.c
+++ b/channels/sip/dialplan_functions.c
@@ -166,8 +166,12 @@
} else if (!strcasecmp(args.param, "uri")) {
ast_copy_string(buf, p->uri, buflen);
} else if (!strcasecmp(args.param, "ruri")) {
- char *tmpruri = REQ_OFFSET_TO_STR(&p->initreq, rlpart2);
- ast_copy_string(buf, tmpruri, buflen);
+ if (p->initreq.data) {
+ char *tmpruri = REQ_OFFSET_TO_STR(&p->initreq, rlpart2);
+ ast_copy_string(buf, tmpruri, buflen);
+ } else {
+ return -1;
+ }
} else if (!strcasecmp(args.param, "useragent")) {
ast_copy_string(buf, p->useragent, buflen);
} else if (!strcasecmp(args.param, "peername")) {
Description: app_voicemail.c: Support for Danish syntax in VM
Added support for playing the correct plural sound file
dependent on whether you have 1 or multipe messages.
.
Based on the existing SE/NO code.
Author: Mark Petersen <bugs.digium.com@zombie.dk>
Source: https://github.com/asterisk/asterisk/commit/ff0b048
Bug: https://issues.asterisk.org/jira/browse/ASTERISK-29797
Last-Update: 2022-01-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -9885,6 +9885,51 @@
return res;
}
+/* Danish syntax */
+static int vm_intro_da(struct ast_channel *chan, struct vm_state *vms)
+{
+ /* Introduce messages they have */
+ int res;
+
+ res = ast_play_and_wait(chan, "vm-youhave");
+ if (res)
+ return res;
+
+ if (!vms->oldmessages && !vms->newmessages && !vms->urgentmessages) {
+ res = ast_play_and_wait(chan, "vm-no");
+ res = res ? res : ast_play_and_wait(chan, "vm-messages");
+ return res;
+ }
+
+ if (vms->newmessages) {
+ if ((vms->newmessages == 1)) {
+ res = ast_play_and_wait(chan, "digits/1");
+ res = res ? res : ast_play_and_wait(chan, "vm-INBOX");
+ res = res ? res : ast_play_and_wait(chan, "vm-message");
+ } else {
+ res = say_and_wait(chan, vms->newmessages, ast_channel_language(chan));
+ res = res ? res : ast_play_and_wait(chan, "vm-INBOXs");
+ res = res ? res : ast_play_and_wait(chan, "vm-messages");
+ }
+ if (!res && vms->oldmessages)
+ res = ast_play_and_wait(chan, "vm-and");
+ }
+ if (!res && vms->oldmessages) {
+ if (vms->oldmessages == 1) {
+ res = ast_play_and_wait(chan, "digits/1");
+ res = res ? res : ast_play_and_wait(chan, "vm-Old");
+ res = res ? res : ast_play_and_wait(chan, "vm-message");
+ } else {
+ res = say_and_wait(chan, vms->oldmessages, ast_channel_language(chan));
+ res = res ? res : ast_play_and_wait(chan, "vm-Olds");
+ res = res ? res : ast_play_and_wait(chan, "vm-messages");
+ }
+ }
+
+ return res;
+}
+
+
/* GERMAN syntax */
static int vm_intro_de(struct ast_channel *chan, struct vm_state *vms)
{
@@ -10365,6 +10410,8 @@
return vm_intro_nl(chan, vms);
} else if (!strncasecmp(ast_channel_language(chan), "no", 2)) { /* NORWEGIAN syntax */
return vm_intro_no(chan, vms);
+ } else if (!strncasecmp(ast_channel_language(chan), "da", 2)) { /* DANISH syntax */
+ return vm_intro_da(chan, vms);
} else if (!strncasecmp(ast_channel_language(chan), "pl", 2)) { /* POLISH syntax */
return vm_intro_pl(chan, vms);
} else if (!strncasecmp(ast_channel_language(chan), "pt_BR", 5)) { /* BRAZILIAN PORTUGUESE syntax */
--- /dev/null
+++ b/doc/CHANGES-staging/app_voicemail_danish_syntax.txt
@@ -0,0 +1,6 @@
+Subject: app_voicemail
+Subject: Applications
+
+added support for Danish syntax, playing the correct plural sound file
+dependen on where you have 1 or multipe messages
+based on the existing SE/NO code
Description: app.c: Throw warnings for nonexistent options
Currently, Asterisk doesn't throw warnings
if options are passed into applications that don't accept them.
This can confuse users if they're unaware
that they are doing something wrong.
.
This adds an additional check to parse_options
so that a warning is thrown anytime an option is parsed
that doesn't exist in the parsing application,
so that users are notified of the invalid usage.
Author: Naveen Albert <asterisk@phreaknet.org>
Source: https://github.com/asterisk/asterisk/commit/1e7bcc2
Bug: https://issues.asterisk.org/jira/browse/ASTERISK-29801
Last-Update: 2022-01-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/main/app.c
+++ b/main/app.c
@@ -2814,6 +2814,9 @@
} else if (argloc) {
args[argloc - 1] = "";
}
+ if (!options[curarg].flag) {
+ ast_log(LOG_WARNING, "Unrecognized option: '%c'\n", curarg);
+ }
if (flaglen == 32) {
ast_set_flag(flags, options[curarg].flag);
} else {
Description: say.conf: fix 12pm noon logic
Fixes 12pm noon incorrectly returning 0/a.m.
Also fixes a misspelling typo in the config.
Author: Naveen Albert <asterisk@phreaknet.org>
Source: https://github.com/asterisk/asterisk/commit/75b9b93
Bug: https://issues.asterisk.org/jira/browse/ASTERISK-29695
Last-Update: 2022-01-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/configs/samples/say.conf.sample
+++ b/configs/samples/say.conf.sample
@@ -90,17 +90,17 @@
_date:[Aa]:. => digits/day-${SAY:16:1} ; day of week
_date:[de]:. => num:${SAY:6:2} ; day of month
_date:[H]:. => digits/oh, num:${SAY:8:2} ; hour (oh one, oh two, ..., oh nine, ten, eleven, ..., twenty-three)
- _date:[I]:. => num:$[${SAY:8:2} % 12] ; hour 0-12
+ _date:[I]:. => num:${IF($[${SAY:8:2} > 12] ? $[${SAY:8:2}%12] : ${SAY:8:2})} ; hour 0-12
_date:[M]:. => num:${SAY:10:2} ; minute
; XXX too bad the '?' function does not remove the quotes
- ; _date:[pP]:. => digits/$[ ${SAY:10:2} > 12 ? "p-m" :: "a-m"] ; am pm
+ ; _date:[pP]:. => digits/$[ ${SAY:10:2} >= 12 ? "p-m" :: "a-m"] ; am pm
_date:[pP]:. => digits/p-m ; am pm
_date:[S]:. => num:${SAY:13:2} ; seconds
_date:[Ii]:. => num:$[${SAY:8:2} % 12] ; hour 0-12
_date:[k]:. => num:${SAY:8:2} ; hour (one, two. three, ...,twenty three
_date:[m]:. => num:${SAY:4:2} ; month number
- _date:[Q]:. => date:dby ;incompleat ; "today", "yesterday" or ABdY
- _date:[q]:. => date:dby ;incompleat ; "" (for today), "yesterday", weekday, or ABdY
+ _date:[Q]:. => date:dby ;incomplete ; "today", "yesterday" or ABdY
+ _date:[q]:. => date:dby ;incomplete ; "" (for today), "yesterday", weekday, or ABdY
_date:[R]:. => date:HM${SAY} ; 24 hour time, including minute
_date:[T]:. => date:HMS${SAY} ; 24 hour, minure, seconds
This diff is collapsed.
Description: utils.c: Remove all usages of ast_gethostbyname()
gethostbyname() and gethostbyname_r() are deprecated
in favor of getaddrinfo()
which we use in the ast_sockaddr family of functions.
Author: Sean Bright <sean.bright@gmail.com>
Source: https://github.com/asterisk/asterisk/commit/6060b9c
Bug: https://issues.asterisk.org/jira/browse/ASTERISK-29819
Last-Update: 2022-01-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/addons/ooh323c/src/ooSocket.c
+++ b/addons/ooh323c/src/ooSocket.c
@@ -537,8 +537,6 @@
int ooGetLocalIPAddress(char * pIPAddrs)
{
int ret;
- struct hostent *hp;
- struct ast_hostent phost;
char hostname[100];
if(pIPAddrs == NULL)
@@ -546,20 +544,11 @@
ret = gethostname(hostname, 100);
if(ret == 0)
{
- if ((hp = ast_gethostbyname(hostname, &phost))) {
- if (hp->h_addrtype == AF_INET6) {
- struct in6_addr i;
- memcpy(&i, hp->h_addr, sizeof(i));
- strcpy(pIPAddrs, (inet_ntop(AF_INET6, &i,
- hostname, sizeof(hostname))) == NULL ? "::1" :
- inet_ntop(AF_INET6, &i, hostname, sizeof(hostname)));
- } else {
- struct in_addr i;
- memcpy(&i, hp->h_addr, sizeof(i));
- strcpy(pIPAddrs, (ast_inet_ntoa(i) == NULL) ? "127.0.0.1" : ast_inet_ntoa(i));
- }
- } else {
+ struct ast_sockaddr addr = { {0,} };
+ if (ast_sockaddr_resolve_first_af(&addr, hostname, PARSE_PORT_FORBID, AF_UNSPEC)) {
return -1;
+ } else {
+ strcpy(pIPAddrs, ast_sockaddr_stringify_addr(&addr));
}
}
else{
--- a/apps/app_festival.c
+++ b/apps/app_festival.c
@@ -281,8 +281,6 @@
int usecache;
int res = 0;
struct sockaddr_in serv_addr;
- struct hostent *serverhost;
- struct ast_hostent ahp;
int fd;
FILE *fs;
const char *host;
@@ -398,15 +396,17 @@
if ((serv_addr.sin_addr.s_addr = inet_addr(host)) == -1) {
/* its a name rather than an ipnum */
- serverhost = ast_gethostbyname(host, &ahp);
+ struct ast_sockaddr addr = { {0,} };
- if (serverhost == NULL) {
- ast_log(LOG_WARNING, "festival_client: gethostbyname failed\n");
+ if (ast_sockaddr_resolve_first_af(&addr, host, PARSE_PORT_FORBID, AF_INET)) {
+ ast_log(LOG_WARNING, "festival_client: ast_sockaddr_resolve_first_af() failed\n");
ast_config_destroy(cfg);
close(fd);
return -1;
}
- memmove(&serv_addr.sin_addr, serverhost->h_addr, serverhost->h_length);
+
+ /* We'll overwrite port and family in a sec */
+ ast_sockaddr_to_sin(&addr, &serv_addr);
}
serv_addr.sin_family = AF_INET;
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -1948,10 +1948,8 @@
int portno;
struct ast_format_cap *peercap;
int peerNonCodecCapability;
- struct sockaddr_in sin;
- struct ast_sockaddr sin_tmp;
+ struct ast_sockaddr addr = { {0,} };
char *codecs;
- struct ast_hostent ahp; struct hostent *hp;
int codec, codec_count=0;
int iterator;
struct mgcp_endpoint *p = sub->parent;
@@ -1971,8 +1969,7 @@
return -1;
}
/* XXX This could block for a long time, and block the main thread! XXX */
- hp = ast_gethostbyname(host, &ahp);
- if (!hp) {
+ if (ast_sockaddr_resolve_first_af(&addr, host, PARSE_PORT_FORBID, AF_INET)) {
ast_log(LOG_WARNING, "Unable to lookup host in c= line, '%s'\n", c);
return -1;
}
@@ -1980,12 +1977,9 @@
ast_log(LOG_WARNING, "Malformed media stream descriptor: %s\n", m);
return -1;
}
- sin.sin_family = AF_INET;
- memcpy(&sin.sin_addr, hp->h_addr, sizeof(sin.sin_addr));
- sin.sin_port = htons(portno);
- ast_sockaddr_from_sin(&sin_tmp, &sin);
- ast_rtp_instance_set_remote_address(sub->rtp, &sin_tmp);
- ast_debug(3, "Peer RTP is at port %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
+ ast_sockaddr_set_port(&addr, portno);
+ ast_rtp_instance_set_remote_address(sub->rtp, &addr);
+ ast_debug(3, "Peer RTP is at port %s\n", ast_sockaddr_stringify(&addr));
/* Scan through the RTP payload types specified in a "m=" line: */
codecs = ast_strdupa(m + len);
while (!ast_strlen_zero(codecs)) {
@@ -4657,6 +4651,30 @@
return res;
}
+/*!
+ * \brief Resolve the given hostname and save its IPv4 address.
+ *
+ * \param[in] hostname The hostname to resolve.
+ * \param[out] sin_addr Pointer to a <tt>struct in_addr</tt> in which to
+ * store the resolved IPv4 address. \c sin_addr will
+ * not be changed if resolution fails.
+ *
+ * \retval 0 if successful
+ * \retval 1 on failure
+ */
+static int resolve_first_addr(const char *hostname, struct in_addr *sin_addr)
+{
+ struct ast_sockaddr addr = { {0,} };
+ struct sockaddr_in tmp;
+
+ if (ast_sockaddr_resolve_first_af(&addr, hostname, PARSE_PORT_FORBID, AF_INET)) {
+ return 1;
+ }
+
+ ast_sockaddr_to_sin(&addr, &tmp);
+ *sin_addr = tmp.sin_addr;
+ return 0;
+}
static int reload_config(int reload)
{
@@ -4665,8 +4683,6 @@
struct mgcp_gateway *g;
struct mgcp_endpoint *e;
char *cat;
- struct ast_hostent ahp;
- struct hostent *hp;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
if (gethostname(ourhost, sizeof(ourhost)-1)) {
@@ -4700,10 +4716,8 @@
/* Create the interface list */
if (!strcasecmp(v->name, "bindaddr")) {
- if (!(hp = ast_gethostbyname(v->value, &ahp))) {
+ if (resolve_first_addr(v->value, &bindaddr.sin_addr)) {
ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
- } else {
- memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr));
}
} else if (!strcasecmp(v->name, "allow")) {
ast_format_cap_update_by_allow_disallow(global_capability, v->value, 1);
@@ -4771,13 +4785,11 @@
if (ntohl(bindaddr.sin_addr.s_addr)) {
memcpy(&__ourip, &bindaddr.sin_addr, sizeof(__ourip));
} else {
- hp = ast_gethostbyname(ourhost, &ahp);
- if (!hp) {
+ if (resolve_first_addr(ourhost, &__ourip)) {
ast_log(LOG_WARNING, "Unable to get our IP address, MGCP disabled\n");
ast_config_destroy(cfg);
return 0;
}
- memcpy(&__ourip, hp->h_addr, sizeof(__ourip));
}
if (!ntohs(bindaddr.sin_port))
bindaddr.sin_port = htons(DEFAULT_MGCP_CA_PORT);
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -1234,8 +1234,6 @@
static char ourhost[256];
static int ourport;
static struct in_addr __ourip;
-static struct ast_hostent ahp;
-static struct hostent *hp;
static int skinnysock = -1;
static pthread_t accept_t;
static int callnums = 1;
@@ -7758,6 +7756,31 @@
return tmpc;
}
+/*!
+ * \brief Resolve the given hostname and save its IPv4 address.
+ *
+ * \param[in] hostname The hostname to resolve.
+ * \param[out] sin_addr Pointer to a <tt>struct in_addr</tt> in which to
+ * store the resolved IPv4 address. \c sin_addr will
+ * not be changed if resolution fails.
+ *
+ * \retval 0 if successful
+ * \retval 1 on failure
+ */
+static int resolve_first_addr(const char *hostname, struct in_addr *sin_addr)
+{
+ struct ast_sockaddr addr = { {0,} };
+ struct sockaddr_in tmp;
+
+ if (ast_sockaddr_resolve_first_af(&addr, hostname, PARSE_PORT_FORBID, AF_INET)) {
+ return 1;
+ }
+
+ ast_sockaddr_to_sin(&addr, &tmp);
+ *sin_addr = tmp.sin_addr;
+ return 0;
+}
+
#define TYPE_GENERAL 1
#define TYPE_DEF_DEVICE 2
#define TYPE_DEF_LINE 4
@@ -7789,10 +7812,8 @@
continue;
}
if (!strcasecmp(v->name, "bindaddr")) {
- if (!(hp = ast_gethostbyname(v->value, &ahp))) {
+ if (resolve_first_addr(v->value, &bindaddr.sin_addr)) {
ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
- } else {
- memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr));
}
continue;
} else if (!strcasecmp(v->name, "keepalive")) {
@@ -8487,13 +8508,11 @@
if (ntohl(bindaddr.sin_addr.s_addr)) {
__ourip = bindaddr.sin_addr;
} else {
- hp = ast_gethostbyname(ourhost, &ahp);
- if (!hp) {
+ if (resolve_first_addr(ourhost, &__ourip)) {
ast_log(LOG_WARNING, "Unable to get our IP address, Skinny disabled\n");
ast_config_destroy(cfg);
return 0;
}
- memcpy(&__ourip, hp->h_addr, sizeof(__ourip));
}
if (!ntohs(bindaddr.sin_port)) {
bindaddr.sin_port = htons(DEFAULT_SKINNY_PORT);
--- a/channels/chan_unistim.c
+++ b/channels/chan_unistim.c
@@ -6847,8 +6847,6 @@
{
struct ast_config *cfg;
struct ast_variable *v;
- struct ast_hostent ahp;
- struct hostent *hp;
struct sockaddr_in bindaddr = { 0, };
char *config = "unistim.conf";
char *cat;
@@ -6916,11 +6914,11 @@
}
} else if (!strcasecmp(v->name, "public_ip")) {
if (!ast_strlen_zero(v->value)) {
- if (!(hp = ast_gethostbyname(v->value, &ahp))) {
+ struct ast_sockaddr addr = { {0,} };
+ if (ast_sockaddr_resolve_first_af(&addr, v->value, PARSE_PORT_FORBID, AF_INET)) {
ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
} else {
- memcpy(&public_ip.sin_addr, hp->h_addr, sizeof(public_ip.sin_addr));
- public_ip.sin_family = AF_INET;
+ ast_sockaddr_to_sin(&addr, &public_ip);
}
}
}
--- a/channels/iax2/provision.c
+++ b/channels/iax2/provision.c
@@ -285,9 +285,6 @@
int foundportno = 0;
int foundserverportno = 0;
int x;
- struct in_addr ia;
- struct hostent *hp;
- struct ast_hostent h;
struct iax_template *src, tmp;
const char *t;
if (def) {
@@ -335,15 +332,15 @@
} else
ast_log(LOG_WARNING, "Ignoring invalid %s '%s' for '%s' at line %d\n", v->name, v->value, s, v->lineno);
} else if (!strcasecmp(v->name, "server") || !strcasecmp(v->name, "altserver")) {
- hp = ast_gethostbyname(v->value, &h);
- if (hp) {
- memcpy(&ia, hp->h_addr, sizeof(ia));
+ struct ast_sockaddr addr = { {0,} };
+ if (ast_sockaddr_resolve_first_af(&addr, v->value, PARSE_PORT_FORBID, AF_INET)) {
+ ast_log(LOG_WARNING, "Ignoring invalid %s '%s' for '%s' at line %d\n", v->name, v->value, s, v->lineno);
+ } else {
if (!strcasecmp(v->name, "server"))
- cur->server = ntohl(ia.s_addr);
+ cur->server = ast_sockaddr_ipv4(&addr);
else
- cur->altserver = ntohl(ia.s_addr);
- } else
- ast_log(LOG_WARNING, "Ignoring invalid %s '%s' for '%s' at line %d\n", v->name, v->value, s, v->lineno);
+ cur->altserver = ast_sockaddr_ipv4(&addr);
+ }
} else if (!strcasecmp(v->name, "codec")) {
struct ast_format *tmpfmt;
if ((tmpfmt = ast_format_cache_get(v->value))) {
--- a/main/config.c
+++ b/main/config.c
@@ -3873,8 +3873,7 @@
/* default is either the supplied value or the result itself */
struct sockaddr_in *def = (flags & PARSE_DEFAULT) ?
va_arg(ap, struct sockaddr_in *) : sa;
- struct hostent *hp;
- struct ast_hostent ahp;
+ struct ast_sockaddr addr = { {0,} };
memset(&_sa_buf, '\0', sizeof(_sa_buf)); /* clear buffer */
/* duplicate the string to strip away the :port */
@@ -3900,12 +3899,13 @@
error = 1;
}
/* Now deal with host part, even if we have errors before. */
- hp = ast_gethostbyname(buf, &ahp);
- if (hp) /* resolved successfully */
- memcpy(&sa->sin_addr, hp->h_addr, sizeof(sa->sin_addr));
- else {
+ if (ast_sockaddr_resolve_first_af(&addr, buf, PARSE_PORT_FORBID, AF_INET)) {
error = 1;
sa->sin_addr = def->sin_addr;
+ } else {
+ struct sockaddr_in tmp;
+ ast_sockaddr_to_sin(&addr, &tmp);
+ sa->sin_addr = tmp.sin_addr;
}
ast_debug(3,
"extract inaddr from [%s] gives [%s:%d](%d)\n",
Description: bridge: Unlock channel during Local peer check.
It's not safe to keep the channel locked
while locking the peer Local channel,
as it can result in a deadlock.
.
This change unlocks it during this time
but keeps the bridge locked
to ensure nothing changes about the bridge.
Author: Joshua C. Colp <jcolp@sangoma.com>
Source: https://github.com/asterisk/asterisk/commit/a363153
Bug: https://issues.asterisk.org/jira/browse/ASTERISK-29821
Last-Update: 2022-01-23
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/main/bridge_channel.c
+++ b/main/bridge_channel.c
@@ -2877,11 +2877,13 @@
ast_bridge_lock(bridge_channel->bridge);
ast_channel_lock(bridge_channel->chan);
-
peer = ast_local_get_peer(bridge_channel->chan);
+
if (peer) {
struct ast_bridge *peer_bridge;
+ ast_channel_unlock(bridge_channel->chan);
+
ast_channel_lock(peer);
peer_bridge = ast_channel_internal_bridge(peer);
ast_channel_unlock(peer);
@@ -2891,7 +2893,6 @@
* to be reference counted or locked.
*/
if (peer_bridge == bridge_channel->bridge) {
- ast_channel_unlock(bridge_channel->chan);
ast_bridge_unlock(bridge_channel->bridge);
ast_debug(1, "Bridge %s: %p(%s) denying Bridge join to prevent Local channel loop\n",
bridge_channel->bridge->uniqueid,
@@ -2899,6 +2900,8 @@
ast_channel_name(bridge_channel->chan));
return -1;
}
+
+ ast_channel_lock(bridge_channel->chan);
}
bridge_channel->read_format = ao2_bump(ast_channel_readformat(bridge_channel->chan));