Ticket #45629

fc_vsnprintf() documented to follow C99, implementation C89 one

Open Date: 2022-09-10 07:14 Last Update: 2022-10-23 08:36

Reporter:
Owner:
Type:
Status:
Closed
Component:
MileStone:
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
Fixed
File:
1

Details

fc_vsnprintf() function header discuss return value, and states that C99 is followed: "If truncation does occur, returns the number of characters which would have been produced without truncation."

The implementation, on the other hand, converts any C99 values to C89 (-1 on truncation), and not vice versa:

/* Convert C99 return value to C89. */ if (r >= n) {

return -1;

}

Ticket History (3/8 Histories)

2022-09-10 07:14 Updated by: cazfi
  • New Ticket "fc_vsnprintf() documented to follow C99, implementation C89 one" created
2022-09-10 07:35 Updated by: cazfi
Comment

While we should fix fc_vsnprintf() to return C99 compatible value when ever possible, there's nothing we can do if the underlying vsnprintf() implementation is not behaving.

- Update the configure check for what is considerd acceptable vsnprintf() implementation -> #45630
- Having fc_vsnprinf() to return C99 value at least most of the time (instead of always returning C89 value) fixes some users, and is unlikely to break any

2022-09-22 01:21 Updated by: cazfi
Comment

While working on this, found #45682, that I think needs to be resolved first (considered a dependency of this)

2022-09-26 04:33 Updated by: cazfi
Comment

Probably first make boundary check improvements in #45719

2022-09-26 04:34 Updated by: cazfi
  • Milestone Update from (None) to 3.0.5 (closed)
  • Component Update from (None) to General
2022-10-15 09:16 Updated by: cazfi
  • Owner Update from (None) to cazfi
  • Resolution Update from None to Accepted
Comment

Meant also to S2_6

2022-10-23 08:36 Updated by: cazfi
  • Status Update from Open to Closed
  • Resolution Update from Accepted to Fixed

Edit

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Login