Fixed problems in URI parsing including memory corruption.
authorJon A. Cruz <jonc@osg.samsung.com>
Fri, 13 Mar 2015 01:29:37 +0000 (18:29 -0700)
committerErich Keane <erich.keane@intel.com>
Wed, 18 Mar 2015 20:17:30 +0000 (20:17 +0000)
commit660230c015022cf5ca258579b7e13d1b25571889
tree10296ac61657a7489e9f11afb53f70454bf056a4
parentf4e213e2b833dc37560bc084f68c32fdb48c83bd
Fixed problems in URI parsing including memory corruption.

Fixed issues in CAParseURI that included

* Use of uint32_t instead of size_t.
  - Passing by address resulted in corruption on 64-bit builds and all
    others where the datatypes are different. This includes various
    embedded devices that have a size_t smaller than uint32_t.

* Miscalculation of offset would freeze parsing once a few path components
  or parameters were processed.
  - While walking parsed results list the buffer-check addition would fail
    and all subsequent path components or parameters (depending on each
    independently) would repeat the contents of a prior item. Thus the end
    of path components and/or parameter parts of the list would be filled
    with repeats of a single value instead of the correct latter values.

* Replaced duplicated code blocks with a single helper function.

* Added unit tests for issue. However the test cases won't be runnable
  until after the build machine issue with connectivity/test is addressed.

Change-Id: Ife3f327ae3bbda518d663bb0d6c5b4c0d8f98e9a
Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/470
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: jihwan seo <jihwan.seo@samsung.com>
Reviewed-by: Joseph Morrow <joseph.l.morrow@intel.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/src/caprotocolmessage.c
resource/csdk/connectivity/test/caprotocolmessagetest.cpp [new file with mode: 0644]