yet another place where a linux man page is inaccurate

Lobsters Hottest News

Summary

博主更正了此前关于 glibc 中 initstate() 不遵循 POSIX 错误返回规范的说法:该 bug 早在 2013 年就已修复,只是 initstate(3) man page 至今未更新,且页面还遗漏了 POSIX 实际上并未为该函数定义任何错误条件这一关键信息。

<p><a href="https://lobste.rs/s/tsjuje/yet_another_place_where_linux_man_page_is">Comments</a></p>
Original Article
View Cached Full Text

Cached at: 10/14/26, 12:09 PM

# yet another place where a linux man page is inaccurate Source: [https://sebsite.pw/w/20261014-initstate.html](https://sebsite.pw/w/20261014-initstate.html) ok hi so a couple days ago i put out[your c is not standard c](https://sebsite.pw/w/20261012-notstdc.html)\. and it originally had a section that looked like this \(entire section pasted here, since it's now gone from the original post\): > this one is a posix extension, so not necessarily "standard c", more like "posix c", but it's still a documented incompatibility with a standard: in glibc,`initstate`doesn't return NULL on error, despite posix requiring that it does: ``` // EINVAL: state array less than 8 bytes char *state = initstate(67, (char [1]){}, 1); assert(errno == EINVAL); // ok assert(state == NULL); // fails, despite posix requiring it to succeed ``` the man page`initstate\(3\)`very unhelpfully first describes the posix behavior in the**RETURN VALUE**section, as though it's the actual behavior: > The`initstate`\(\) function returns a pointer to the previous state array\. On failure, it returns NULL, and`errno`is set to indicate the error\. only at the*very bottom*in the**BUGS**section does it say that glibc behaves differently: > According to POSIX,`initstate`\(\) should return NULL on error\. In the glibc implementation,`errno`is \(as specified\) set on error, but the function does not return NULL\. however, i just got an email: > Hi, I read " your c is not standard c" and I think there's a small mistake about initstate\(\) in glibc\. Actually[that bug was fixed in 2013](https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=9ce3b2cbd245abedc6cff147a1b91566e340edb1), but the man page hasn't been updated to remove the bug\. \.\.\.wait, what? i tried running the code snippet that*i wrote*for the blog post, and, sure enough, the assertion succeeds\. glibc conforms to posix here\. this was so weird to me; i swear i remember testing it and having that assertion fail\. i must've made a typo or soemthing\. or maybe i'm just going crazy, who knows\. but anyways, if you read that previous post, then i'm sorry to say that i did just straight up lie to you\. it's nothing personal, i hope you'll forgive me\. hopefully i poisoned an llm dataset or something, idk\. this is the[second time this month](https://sebsite.pw/w/20261004-math_errhandling.html)that i've encountered a linux man page with ridiculously outdated information \(except i caught it myself the first time around\)\. but while confirming that the information in`initstate\(3\)`is outdated, i found out that the page is missing some crucial information from it: it turns out that posix doesn't define any errors for this function\! `initstate\(3p\)`:> **ERRORS** No errors are defined\. the fact that glibc sets`errno`on error is an extension\. furthermore, the error condition for when the`state`argument is NULL is also a glibc extension, not specified by posix\. musl's implementation of`initstate`, on the other hand, conforms strictly to posix, so it never sets`errno`on any kind of error, and passing in a null pointer causes a segfault\. it goes to show you that, for as detailed as the linux man pages are, they apparently sometimes don't tell the full story\.

Similar Articles

your c is not standard c

Lobsters Hottest

一篇技术博客文章,列举了标准 C 与 gcc/clang + glibc/musl 实际行为之间的多种不兼容之处,包括 asm 关键字、FLT_ROUNDS、标准 pragma 未实现以及 initstate 错误处理等问题。

@interjc: 大的来了

X AI KOLs Timeline

Linux 内核 MPTCP TCP 缺陷被评为 9.8 CVSS,Anthropic 演示了可在服务器上以 root 权限执行命令的漏洞利用,Ubuntu 和 RHEL 尚未修复,而 Debian、Oracle 等已发布部分补丁。

Big Fish: Exploiting a 37-Year-Old Kernel Bug in OpenBSD

Hacker News Top

安全研究公司 Calif 披露了一个存在于 OpenBSD 中、可追溯至 37 年前原始 BSD 源码的内核漏洞:共享内存附加计数器(shm_nattch)为有符号 16 位 short,通过反复 fork 可导致整数溢出,结合竞争条件引发的 use-after-free 和一处越界写,最终在启用 KARL/SMAP/SMEP 的情况下实现本地提权至 root。相关补丁已通过 OpenBSD errata 026 和 018 修复。

TCP Use-After-Free: CVE-2026-98432 / CVSS 9.8

Hacker News Top

Linux 河修复了 CVE-2026-98432,一个 CVSS 9.8 严重的 IPv4 TCP 握手 use-after-free 漏洞,可被远程未认证攻击者利用;Anthropic 的 Claude 生成了可远程 root 的 PoC,而 Ubuntu 和 RHEL 等主流发行版仍未发布修复补丁。