summaryrefslogtreecommitdiff
path: root/channels/sip
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2014-10-31 03:26:00 +0000
committerMatthew Jordan <mjordan@digium.com>2014-10-31 03:26:00 +0000
commitf6809b01df4a958d493f12d2c286a86193a8775a (patch)
treea2ad667be0524256b27b5d86c12aad2534b27bb9 /channels/sip
parentb2320497f8f0372e09b544f749978b793cd49e10 (diff)
channels/sip/reqresp_parser: Fix unit tests for r426594
When r426594 was made, it did not take into account a unit test that verified that the function properly populated the unsupported buffer. The function would previously memset the buffer if it detected it had any contents; since this function can now be called iteratively on successive headers, the unit tests would now fail. This patch updates the unit tests to reset the buffer themselves between successive calls, and updates the documentation of the function to note that this is now required. ........ Merged revisions 426858 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 426860 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 426863 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@426865 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/sip')
-rw-r--r--channels/sip/include/reqresp_parser.h5
-rw-r--r--channels/sip/reqresp_parser.c2
2 files changed, 6 insertions, 1 deletions
diff --git a/channels/sip/include/reqresp_parser.h b/channels/sip/include/reqresp_parser.h
index 7f9c8f6d9..2543329dd 100644
--- a/channels/sip/include/reqresp_parser.h
+++ b/channels/sip/include/reqresp_parser.h
@@ -176,6 +176,11 @@ void sip_request_parser_unregister_tests(void);
* \param option list
* \param unsupported out buffer (optional)
* \param unsupported out buffer length (optional)
+ *
+ * \note Because this function can be called multiple times, it will append
+ * whatever options are specified in \c options to \c unsupported. Callers
+ * of this function should make sure the unsupported buffer is clear before
+ * calling this function.
*/
unsigned int parse_sip_options(const char *options, char *unsupported, size_t unsupported_len);
diff --git a/channels/sip/reqresp_parser.c b/channels/sip/reqresp_parser.c
index aa568a0e9..e5c1ff2bc 100644
--- a/channels/sip/reqresp_parser.c
+++ b/channels/sip/reqresp_parser.c
@@ -1698,7 +1698,6 @@ unsigned int parse_sip_options(const char *options, char *unsupported, size_t un
temp = ast_strdupa(options);
ast_debug(3, "Begin: parsing SIP \"Supported: %s\"\n", options);
-
for (next = temp; next; next = sep) {
found = FALSE;
supported = FALSE;
@@ -1858,6 +1857,7 @@ AST_TEST_DEFINE(sip_parse_options_test)
/* Test with unsupported char buffer */
AST_LIST_TRAVERSE(&testdatalist, testdataptr, list) {
+ memset(unsupported, 0, sizeof(unsupported));
option_profile = parse_sip_options(testdataptr->input_options, unsupported, ARRAY_LEN(unsupported));
if (option_profile != testdataptr->expected_profile ||
strcmp(unsupported, testdataptr->expected_unsupported)) {