Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-5448

WSDL2C: sporadic failures in deserializer code generated for xs:date, returns wrong date value

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.6.2
    • None
    • adb, codegen
    • None
    • iOS 5.1 or MacOS X 10.7.5

    Description

      The xml deserializer code generated for xs:date calls axutil_date_time_deserialize_date_time()
      instead of axutil_date_time_deserialize_date() to convert a date from string format (e.g. "2012-09-30")
      to a axutil_date_time_t.

      This results in random failures parsing the date. The deserialized date sometimes contains the current date instead of the date value that was present in the xml data.

      How does it fail in axutil_date_time_deserialize_date_time() ? It fails because:

      • A wrong sscanf format string is used to parse the date, sscanf is unable to fill all arguments. sscanf returns 3, and axutil_date_time_deserialize_date_time() does not recognize this failure.
      • after that, axutil_date_time_deserialize_date_time() accesses uninitialized variables for "hour",
        "min", and "sec", and may randomly return parse errors, because hour, min, sec contain a value that is out of range. The end result is that sometimes no parsed date is written to the deserialized date, and we get the current date instead.

      In the debugger, we have this:

      (gdb) bt
      #0 axutil_date_time_deserialize_date_time (date_time=0x1001024d0, env=0x1001009b0, date_time_str=0x100102410 "2012-09-30") at date_time.c:275
      #1 0x0000000100002a9d in adb_ISODate_deserialize_from_string (_ISODate=0x100102380, env=0x1001009b0, node_value=0x100102410 "2012-09-30", parent=0x0) at adb_ISODate.c:180
      #2 0x0000000100002bcd in adb_ISODate_deserialize_obj (_ISODate=0x100102380, env=0x1001009b0, dp_parent=<value temporarily unavailable, due to optimizations>, dp_is_early_node_valid=0x0, dont_care_minoccurs=1352029547) at adb_ISODate.c:256
      #3 0x0000000100001de8 in adb_Document_deserialize_obj (_Document=0x100101a40, env=0x1001009b0, dp_parent=<value temporarily unavailable, due to optimizations>, dp_is_early_node_valid=<value temporarily unavailable, due to optimizations>, dont_care_minoccurs=0) at adb_Document.c:367
      #4 0x0000000100001548 in main (argc=<value temporarily unavailable, due to optimizations>, argv=<value temporarily unavailable, due to optimizations>) at test.c:44
      (gdb) n
      271 if(*date_time_str == '-')
      (gdb) n
      275 sscanf(date_time_str + is_year_neg, "%d-%d-%dT%d:%d:%fZ", &year, &mon, &day, &hour, &min, &sec);
      (gdb) p hour
      $8 = 1352028776
      (gdb) p min
      $9 = 1113587712
      (gdb) p sec
      $10 = 1.4821702e-39
      (gdb) n
      271 if(*date_time_str == '-')
      (gdb) print $rax
      $11 = 3
      (gdb) p hour
      $12 = 1352028776
      (gdb) p min
      $13 = 1113587712
      (gdb) p sec
      $14 = 1.4821702e-39
      (gdb) p year
      $15 = 2012
      (gdb) p mon
      $17 = 9
      (gdb) p day
      $18 = 30
      (gdb) c
      Continuing.

      OK (<-- xml deserializer returned AXIS2_SUCCESS)
      2012-11-04 (<-- wrong date, expected date is 2012-09-30)

      Attachments

        1. test.c
          1 kB
          Jürgen Keil
        2. Makefile
          0.4 kB
          Jürgen Keil
        3. bug_date.xsd
          0.7 kB
          Jürgen Keil
        4. bug_date.xml
          0.2 kB
          Jürgen Keil
        5. bug_date.wsdl
          1 kB
          Jürgen Keil

        Activity

          People

            Unassigned Unassigned
            jkeil Jürgen Keil
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: