[Rpm-maint] [rpm-software-management/rpm] rpmfiArchiveRead() use signed return value to handle -1 on error (#1188)
Panu Matilainen
notifications at github.com
Wed May 13 08:07:04 UTC 2020
> I actually modeled this on read(2) which also takes a size_t as count argument, but returns an ssize_t as response.
The problem is, read() (and write() for that matter) are dreadful APIs. I think APIs should be designed to be easy to use correctly and hard to misuse, and these both are the opposite due to the sign mismatch. It's like the deitys of Unix were feeling bored and threw a curveball to see just how many subtle ways to get it wrong people would come up with.
A little misdesign never prevented anybody from copying though, looking closer I see rpm itself already duplicates this API bug in several places, including the underlying rpmcpioRead() call, and Fread() and Fwrite() underneath those. The things ones memory protects you from...
> If we're worried about range on 32 bit systems, we could also make it an
int64_t, or the caller should just call multiple times?
This is expected to be called multiple times as it is.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/1188#issuecomment-627822033
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20200513/39d52f47/attachment.html>
More information about the Rpm-maint
mailing list