Skip to content

Commit f3cf120

Browse files
rstowinterz
authored andcommitted
icaltypes.c: fix bug ignoring non-empty REQUEST-STATUS extdata
Due to an erroneous conditional, a non-empty 'extdata' part of a REQUEST-STATUS property value did not get parsed into the 'debug' field of the icalreqstattype struct type. It also fixes the docstring in the header that mistakenly stated that the 'debug' field value points into the original input string. Instead, it points into the ring buffer memory.
1 parent 9653df5 commit f3cf120

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

Diff for: src/libical/icaltypes.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ struct icalreqstattype icalreqstattype_from_string(const char *str)
140140
*/
141141

142142
p2 = strchr(p1 + 1, ';');
143-
if (p2 != 0 && *p2 != 0 && *p2 != ';') { // skipping empty debug strings
143+
if (p2 != 0 && *(p2 + 1) != 0) { // skipping empty debug strings
144144
stat.debug = icalmemory_tmp_copy(p2 + 1);
145145
}
146146

Diff for: src/libical/icaltypes.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ LIBICAL_ICAL_EXPORT bool icaltriggertype_is_bad_trigger(struct icaltriggertype t
4545
/* struct icalreqstattype. This struct contains two string pointers,
4646
but don't try to free either of them. The "desc" string is a pointer
4747
to a static table inside the library. Don't try to free it. The
48-
"debug" string is a pointer into the string that the called passed
49-
into to icalreqstattype_from_string. Don't try to free it either, and
50-
don't use it after the original string has been freed.
48+
"debug" string is allocated in the ring buffer. Don't try to free it
49+
either.
5150
5251
BTW, you would get that original string from
5352
*icalproperty_get_requeststatus() or icalvalue_get_text(), when

Diff for: src/test/regression.c

-2
Original file line numberDiff line numberDiff line change
@@ -1778,11 +1778,9 @@ void test_requeststat(void)
17781778
}
17791779
p = icalcomponent_get_first_property(c, ICAL_REQUESTSTATUS_PROPERTY);
17801780

1781-
#if ADD_TESTS_REQUIRING_INVESTIGATION
17821781
str_is("icalproperty_new_from_string()",
17831782
icalproperty_as_ical_string(p),
17841783
"REQUEST-STATUS:2.1;Success but fallback taken on one or more property \r\n values.;booga\r\n");
1785-
#endif
17861784
icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR, ICAL_ERROR_NONFATAL);
17871785
st2 = icalreqstattype_from_string("16.4");
17881786

0 commit comments

Comments
 (0)