Hi Sam, On Sun, Apr 28, 2024 at 10:37:23AM +0200, Alejandro Colomar wrote: > On Sun, Apr 28, 2024 at 02:19:55AM +0100, Sam James wrote: > > With regard to d0d2e2f9a21e623db208b599643e7728d71e7e6f specifically, it > > might be worth explaining: a) what liba2i is; I forgot to explain what liba2i is. You know, but for the list: I've been contributing to the shadow project for some years, and maintaining its stable branches for half a year. While doing that, I found consistent misuses of strto[u]l(3) and its family of functions. And in the cases where it was correctly being used, the code was less than desirable. I claim that it's due to the messy interface of those functions; while they are useful, they are very difficult to use correctly. The first problem I fixed was that strtoul(3) doesn't reject negative numbers, and behaves in a way most programmers wouldn't expect (unless they know that function really well). <https://github.com/shadow-maint/shadow/pull/875> Then, I tried to do was use the NetBSD APIs strtoi/u(3), which are provided by libbsd for GNU/Linux systems. However, I realized that it was still imperfect, since it doesn't provide type safety. Also, since Fedora and some other systems don't want libbsd as a dependency of shadow, I had to implement my own strtoi(3) to work when shadow wasn't being linked to libbsd. <https://github.com/shadow-maint/shadow/pull/890> When testing my implementation and libbsd's one, I realized that they behaved different in a corner case, which results it was a bug in the original design of the function. Luckily, it was an undocumented behavior, and we could fix it (and BTW, fixing it, fixed many existing calls in both NetBSD and Debian). <https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57828> I found an old internal function of the shadow project, getlong(), which seemed to have a better API, which provided type safety. I then came up with a design for a set of functions and macros which would be a hybrid between shadow's getlong() and NetBSD's strtoi(3). Those functions have already been added to shadow recently. <https://github.com/shadow-maint/shadow/pull/891> And now I have a huge patch set for modifying the entire code base to use calls to those new functions, replacing every call to older APIs. <https://github.com/shadow-maint/shadow/pull/893> While changing all uses to use the new APIs that I designed, I found several bugs in the process, which are being fixed (most silently, with no bug reports). In some cases, I found code that is pasted from other projects (e.g., the reproducible builds project). That's why I thought that writing a small library that would house these APIs would be an improvement to many projects, not just this one. The project is hosted in <kernel.org>. It has a mailing list (CCed in this message). <https://git.kernel.org/pub/scm/libs/liba2i/liba2i.git> I wrote a build system for it based on the one in this project, the Linux man-pages. I'm trying to keep both build systems as similar as possible, to reduce the job of maintaining both. For that, I use diffoscope(1), to see the differences in every file. Have a lovely day! Alex -- <https://www.alejandro-colomar.es/> A client is hiring kernel driver, mm, and/or crypto developers; contact me if interested.
Attachment:
signature.asc
Description: PGP signature