Repository navigation
Description
Specify which documentation you found a problem with
docs/libcurl/curl_version_info.md
The problem
The documentation talks about the caller setting the age parameter appropriately, so that:
libcurl always returns a proper struct that your program understands, while programs in the future might get a different struct.
Later, it also says about age:
You are however guaranteed to get a struct that you have a matching struct for in the header, as you tell libcurl your "age" with the input argument.
However, that age parameter is currently completely ignored in the function. This means that if the returned struct changes in a backward-incompatible way in the future, a future application dynamically-linked to an older libcurl will receive the older struct, despite asking for a newer one, contrary to the documentation.
Since there is no way to return an error indication to the caller if this ever occurs, this documented behaviour can never be honoured. This also means that the implication that the returned struct may some day be incompatible can also never occur without also breaking the ABI.
Applications relying on this behaviour even in the face of backwards-compatible struct changes will also end up with a OOB read. For example, an application might need the feature_names field, so it sets stamp to CURLVERSION_ELEVENTH. However, the binary is run on an old OS with libcurl 7.86.0 that doesn't have this field. The application believes the guarantee libcurl always returns a proper struct that your program understands and reads that field (an OOB read) and even if that itself doesn't result in a segfault, when it dereferences that pointer it just read, it will almost be guaranteed one.
A thoughtful programmer should realize that this reading of the documentation does not and cannot make sense, but we shouldn't be making these kind of impossible guarantees.
This guarantee in the documentation should be removed. Instead, the caller should be admonished instead to check the returned age parameter in the struct. If that value is less than CURLVERSION_NOW (or another fixed CURLVERSION_* value determined by the developer), then the struct should not be dereferenced or it could result in a OOB read. This should be made explicit rather than implicit, as it is now.
Furthermore, if we ever want to reserve the ability to change the struct in backward-incompatible ways using the age parameter, we need to define a way of returning an error if the age request can't be satisfied. This could be by returning NULL or by defining an error field in the struct. Or, we drop the idea that we could ever do this.
Activity
vszakats commentedon Mar 21, 2026
Would it be perhaps more self-explanatory if the accepted
curl_version_info()argument
stampwould be nameddummy/deprecatedand documented asno-op / for-compatibility?
Since its introduction dc9e415 this
argument hasn't played a role, and for reasons in OP, it likely won't in the future?
(This may of course come with a documentation update.)
bagder commentedon Mar 21, 2026
It should never do that. I don't think we ever intended that either. The struct can grow, nothing else.
dfandrich commentedon Mar 22, 2026
The existence of a stamp parameter implies that some kind of run-time change of the return value was considered. If the buffer was provided by the user, then it would be mandatory to avoid overwriting a too-small buffer, but not if libcurl controls the allocation. I could see it being used one day if the struct ever needs to be "reset", either due to mistakes in its implementation, it getting to large, or to completely rework how the data are returned. Callers will have to check the returned age in that case, too, so that's advice that should be documented now. It's probably better to just create a
curl_version_info2()if we ever find the need for a backwards-incompatible struct change.bagder commentedon Mar 22, 2026
Yes, but I think we never could figure of a good way to use it, that would actually work and be a good API.
Absolutely. But I can't recall anyone ever having mentioned problems with the existing one.
curl_version_info.md: clarify age details
dfandrich commentedon Mar 24, 2026
That's much more clear—thanks.
curl_version_info.md: clarify age details