Ratatoi是一个C语言库,它像atoi一样包装了stdlib的strtol函数,但是它很危险。
Ratatoi is a C libary that wraps stdlib's strtol (as atoi does), but it's evil.

原始链接: https://github.com/rept0id/ratatoi

🐀🥄🍲 Ratatoi是一个C语言库,它包装了stdlib的strtol函数(就像atoi一样),但它很邪恶。如果检测到溢出,它会调用abort(),导致程序崩溃并输出Aborted (core dumped)。通过这种方式,它优先考虑内存安全,而不是默默地在错误状态下运行,而无需在每个地方手动调用strtol并检查错误。

The Hacker News thread discusses "Ratatoi," a C library that wraps `strtol` and crashes on errors like overflow, prioritizing safety over silent failures. Commenters debate the design of `strtol`, criticizing its error handling (relying on `errno` and `endptr`) as cumbersome. Alternatives like OpenBSD's `strtonum` and custom wrappers are suggested. Some argue crashing is acceptable for non-recoverable errors, especially during startup, while others worry about denial-of-service vulnerabilities. The discussion also touches on `strtol`'s const correctness issues and the complexities of error handling in C. It also raises the issues that crashing may be acceptable for non-recoverable errors, especially during startup and it also highlights the risks of denial-of-service vulnerabilities.

原文

🐀🥄🍲

Ratatoi is a C libary that wraps stdlib's strtol (as atoi does), but it's evil.

If an overflow is detected, it calls abort(), you crash and get Aborted (core dumped).

This way, you prioritize memory safety over silently running in a wrong state, without needing to call strtol and check errors manually everywhere.

联系我们 contact @ memedata.com