]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
channels/sip/reqresp_parser: Fix unit tests for r426594
authorMatthew Jordan <mjordan@digium.com>
Fri, 31 Oct 2014 03:24:24 +0000 (03:24 +0000)
committerMatthew Jordan <mjordan@digium.com>
Fri, 31 Oct 2014 03:24:24 +0000 (03:24 +0000)
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.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@426858 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/sip/include/reqresp_parser.h
channels/sip/reqresp_parser.c

index 02b046bc72f7da7e0094e7b9c73b0bbf6f6b0c85..8fb803592c5110878841e2cb85d5cf40fa4d08b2 100644 (file)
@@ -152,6 +152,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);
 
index 5402b96d1c6fc7274fd79b46b4384aeb1c27d5fe..88e2902739d4aa715d2ba87b103affe247153c3a 100644 (file)
@@ -1601,7 +1601,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;
@@ -1761,6 +1760,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)) {