1. catopen("", 0) should set errno to ENOENT; 2. Document EFTYPE. POSIX says nothing about how to report a corrupt catalog. NetBSD and OpenBSD do nothing (errno == 0), while we set EFTYPE. Document it. 3. Fix errno under a rare condition (fstat(2) fails after open(2)).
Further points out more EFTYPE errors. The exact explanation of EFTYPE here should be "The file designated by the named catalog is not a regular file or a symbolic link pointing to a regular file, or its data format is not POSIX NLS catalog.", which confirms with the general meaning of EFTYPE "Inappropriate file type or format. The file was the wrong type for the operation, or a data file had the wrong format.". Please help improve the wording in catopen.3 is you find that the current version is not enough. -- Zhihao Yuan, nickname lichray The best way to predict the future is to invent it. ___________________________________________________ 4BSD -- http://4bsd.biz/
batch change of PRs untouched in 2018 marked "in progress" back to open.
Now catopen("", 0) sets errno to ENOENT.
https://reviews.freebsd.org/D34747
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=1176390d2d2bbb1e207c840d1f7a66a6ac1096ff commit 1176390d2d2bbb1e207c840d1f7a66a6ac1096ff Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-11-03 12:50:32 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-11-03 16:59:15 +0000 catopen(3): align returned errors with IEEE Std 1003.1™-2024 - Invalid/non-existent/unable to use message catalog file should result in ENOENT, and not in EFTYPE. - Added detection of several cases of wrong file format due to length [*]. - Update man page. * Based on the original patch from PR. PR: 172805 Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D47413 lib/libc/nls/catopen.3 | 13 +++++++------ lib/libc/nls/msgcat.c | 30 +++++++++++++++++++----------- 2 files changed, 26 insertions(+), 17 deletions(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=d43c3ae472ad2a05bedfe10baf14741570d85c72 commit d43c3ae472ad2a05bedfe10baf14741570d85c72 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-11-03 12:50:32 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-11-09 19:31:28 +0000 catopen(3): align returned errors with IEEE Std 1003.1™-2024 PR: 172805 (cherry picked from commit 1176390d2d2bbb1e207c840d1f7a66a6ac1096ff) lib/libc/nls/catopen.3 | 13 +++++++------ lib/libc/nls/msgcat.c | 30 +++++++++++++++++++----------- 2 files changed, 26 insertions(+), 17 deletions(-)