about summary refs log tree commit diff
Commit message (Collapse)AuthorAgeFilesLines
* Disable _FILE_OFFSET_BITS if the compiler defaults to itAdhemerval Zanella2024-10-014-1/+49
| | | | | | | | | | | | | | | | | Even though building glibc with LFS flags is not supported, and the the usual way is to patch the build system to avoid it [1]; some system do enable it by default, and it increases the requirements to build glibc in such cases (it also does not help newcomers when trying to build glibc). The conform namespace and linknamespace tests also do not expect that flag to be set by default, so disable it as well. Checked with a build/check for major ABI and some (i386, arm, mipsel, hppa) with a toolchain that has LFS flags by default. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=31624 Reviewed-by: DJ Delorie <dj@redhat.com>
* Do not use -Wp to disable fortify (BZ 31928)Adhemerval Zanella2024-10-016-16/+17
| | | | | | | | | | | | | | | | | The -Wp does not work properly if the compiler is configured to enable fortify by default, since it bypasses the compiler driver (which defines the fortify flags in this case). This patch is similar to the one used on Ubuntu [1]. I checked with a build for x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu, s390x-linux-gnu, and riscv64-linux-gnu with gcc-13 that enables the fortify by default. Co-authored-by: Matthias Klose <matthias.klose@canonical.com> [1] https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/glibc/tree/debian/patches/ubuntu/fix-fortify-source.patch Reviewed-by: DJ Delorie <dj@redhat.com>
* libio: Set _vtable_offset before calling _IO_link_in [BZ #32148]H.J. Lu2024-10-013-1/+95
| | | | | | | | | | | Since _IO_vtable_offset is used to detect the old binaries, set it in _IO_old_file_init_internal before calling _IO_link_in which checks _IO_vtable_offset. Add a glibc 2.0 test with copy relocation on _IO_stderr_@GLIBC_2.0 to verify that fopen won't cause memory corruption. This fixes BZ #32148. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* Add a new fwrite test that exercises buffer overflowTulio Magno Quites Machado Filho2024-09-302-0/+131
| | | | | | | | | | | | | | Exercises fwrite's internal buffer when doing a file operation. The new test, exercises 2 overflow behaviors: 1. Call fwrite multiple times making usage of fwrite's internal buffer. The total number of bytes written is larger than fwrite's internal buffer, forcing an automatic flush. 2. Call fwrite a single time with an amount of data that is larger than fwrite's internal buffer. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* x86/string: Fixup alignment of main loop in str{n}cmp-evex [BZ #32212]Noah Goldstein2024-09-301-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The loop should be aligned to 32-bytes so that it can ideally run out the DSB. This is particularly important on Skylake-Server where deficiencies in it's DSB implementation make it prone to not being able to run loops out of the DSB. For example running strcmp-evex on 200Mb string: 32-byte aligned loop: - 43,399,578,766 idq.dsb_uops not 32-byte aligned loop: - 6,060,139,704 idq.dsb_uops This results in a 25% performance degradation for the non-aligned version. The fix is to just ensure the code layout is such that the loop is aligned. (Which was previously the case but was accidentally dropped in 84e7c46df). NB: The fix was actually 64-byte alignment. This is because 64-byte alignment generally produces more stable performance than 32-byte aligned code (cache line crosses can affect perf), so if we are going past 16-byte alignmnent, might as well go to 64. 64-byte alignment also matches most other functions we over-align, so it creates a common point of optimization. Times are reported as ratio of Time_With_Patch / Time_Without_Patch. Lower is better. The values being reported is the geometric mean of the ratio across all tests in bench-strcmp and bench-strncmp. Note this patch is only attempting to improve the Skylake-Server strcmp for long strings. The rest of the numbers are only to test for regressions. Tigerlake Results Strings <= 512: strcmp : 1.026 strncmp: 0.949 Tigerlake Results Strings > 512: strcmp : 0.994 strncmp: 0.998 Skylake-Server Results Strings <= 512: strcmp : 0.945 strncmp: 0.943 Skylake-Server Results Strings > 512: strcmp : 0.778 strncmp: 1.000 The 2.6% regression on TGL-strcmp is due to slowdowns caused by changes in alignment of code handling small sizes (most on the page-cross logic). These should be safe to ignore because 1) We previously only 16-byte aligned the function so this behavior is not new and was essentially up to chance before this patch and 2) this type of alignment related regression on small sizes really only comes up in tight micro-benchmark loops and is unlikely to have any affect on realworld performance. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* stdio-common: Fix memory leak in tst-freopen4* tests on UNSUPPORTEDFlorian Weimer2024-09-281-1/+3
| | | | The temp_dir allocation leaks if support_can_chroot returns false.
* Linux: Block signals around _Fork (bug 32215)Florian Weimer2024-09-281-0/+7
| | | | | | | This hides the inconsistent TCB state (missing robust mutex list) from signal handlers. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Update to Unicode 16.0.0 [BZ #32168]Mike FABIAN2024-09-2715-3099/+14404
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unicode 16.0.0 Support: Character encoding, character type info, and transliteration tables are all updated to Unicode 16.0.0, using the generator scripts contributed by Mike FABIAN (Red Hat). Changes in CHARMAP and WIDTH: Total added characters in newly generated CHARMAP: 5185 Total removed characters in newly generated WIDTH: 1 Total added characters in newly generated WIDTH: 170 The removed character from WIDTH is U+1171E AHOM CONSONANT SIGN MEDIAL RA. It changed like this: UnicodeData.txt 15.1.0: 1171E;AHOM CONSONANT SIGN MEDIAL RA;Mn;0;NSM;;;;;N;;;;; UnicodeData.txt 16.0.0: 1171E;AHOM CONSONANT SIGN MEDIAL RA;Mc;0;L;;;;;N;;;;; EastAsianWidth.txt 15.1.0: 1171D..1171F ; N # Mn [3] AHOM CONSONANT SIGN MEDIAL LA..AHOM CONSONANT SIGN MEDIAL LIGATING RA EastAsianWidth.txt 16.0.0: 1171E ; N # Mc AHOM CONSONANT SIGN MEDIAL RA I.e it changed from Mn (Mark Nonspacing) to Mc (Mark Spacing combining). So it should now have width 1 instead of 0, therefore it is OK that it was removed from WIDTH, characters not in WIDTH get width 1 by default. Nothing suspicious when browsing the list of the 170 added characters. Changes in ctype: alpha: Added 4452 characters in new ctype which were not in old ctype combining: Added 51 characters in new ctype which were not in old ctype combining_level3: Added 43 characters in new ctype which were not in old ctype graph: Added 5185 characters in new ctype which were not in old ctype lower: Added 25 characters in new ctype which were not in old ctype print: Added 5185 characters in new ctype which were not in old ctype punct: Missing 33 characters of old ctype in new ctype punct: Added 766 characters in new ctype which were not in old ctype tolower: Added 27 characters in new ctype which were not in old ctype totitle: Added 27 characters in new ctype which were not in old ctype toupper: Added 27 characters in new ctype which were not in old ctype upper: Added 27 characters in new ctype which were not in old ctype Nothing suspicous in the additions. About the 33 characters removed from `punct`: U+0363 - U+036F are identical in UnicodeData.txt. Difference in DerivedCoreProperties.txt: DerivedCoreProperties.txt 15.1.0: not there. DerivedCoreProperties.txt 16.0.0: 0363..036F ; Alphabetic # Mn [13] COMBINING LATIN SMALL LETTER A..COMBINING LATIN SMALL LETTER X So that’s the reason why they are added to `alpha` and removed from `punct`. Same for U+1DD3 - U+1DE6, they are identical in UnicodeData.txt but there is a difference in DerivedCoreProperties.txt: DerivedCoreProperties.txt 15.1.0: 1DE7..1DF4 ; Alphabetic # Mn [14] COMBINING LATIN SMALL LETTER ALPHA..COMBINING LATIN SMALL LETTER U WITH DIAERESIS DerivedCoreProperties.txt 16.0.0: 1DD3..1DF4 ; Alphabetic # Mn [34] COMBINING LATIN SMALL LETTER FLATTENED OPEN A ABOVE..COMBINING LATIN SMALL LETTER U WITH DIAERESIS So they became `Alphabetic` and were thus added to `alpha` and removed from `punct`. Resolves: BZ #32168 Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* manual: Document that feof and ferror are mutually exclusiveFlorian Weimer2024-09-271-0/+9
| | | | | | | | This is not completely clear from the C standard (although there is footnote number 289 in C11), but I assume that our implementation works this way. Reviewed-by: DJ Delorie <dj@redhat.com>
* stdio-common: Add new test for fdopenSergey Kolosov2024-09-262-0/+247
| | | | | This commit adds fdopen test with all modes. Reviewed-by: DJ Delorie <dj@redhat.com>
* Fix missing randomness in __gen_tempname (bug 32214)Andreas Schwab2024-09-261-0/+2
| | | | | | Make sure to update the random value also if getrandom fails. Fixes: 686d542025 ("posix: Sync tempname with gnulib")
* arc: Cleanup arcbePavel Kozlov2024-09-254-17/+4
| | | | | | | Remove the mention of arcbe ABI to avoid any mislead. ARC big endian ABI is no longer supported. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* arc: Remove HAVE_ARC_BE macro and disable big-endian portFlorian Weimer2024-09-255-21/+6
| | | | It is no longer needed, now that ARC is always little endian.
* scripts: Remove arceb-linux-gnu from build-many-glibcs.pyFlorian Weimer2024-09-251-3/+0
| | | | | | | | This was discussed on the hallway track at GNU Tools Cauldron 2024. There are concerns about stability of the big-endian GCC backend, and Linux removed support for the only big-endian ARC platform in commit dd7c7ab01a04d645b7e7baa8530bfd81e31a2202 ("ARC: [plat-eznps]: Drop support for EZChip NPS platform").
* LoongArch: Undef __NR_fstat and __NR_newfstatat.caiyinyu2024-09-251-0/+21
| | | | | | | | | | | In Linux 6.11, fstat and newfstatat are added back. To avoid the messy usage of the fstat, newfstatat, and statx system calls, we will continue using statx only in glibc, maintaining consistency with previous versions of the LoongArch-specific glibc implementation. Signed-off-by: caiyinyu <caiyinyu@loongson.cn> Reviewed-by: Xi Ruoyao <xry111@xry111.site> Suggested-by: Florian Weimer <fweimer@redhat.com>
* Add tests of freadJoseph Myers2024-09-242-0/+135
| | | | | | | There seem to be no glibc tests specifically for the fread function. Add basic tests of that function. Tested for x86_64.
* nptl: Prefer setresuid32 in tst-setuid2Florian Weimer2024-09-241-0/+5
| | | | | | | Use the setresuid32 system call if it is available, prefering it over setresuid. If both system calls exist, setresuid is the 16-bit variant. This fixes a build failure on sparcv9-linux-gnu.
* elf: Move __rtld_malloc_init_stubs call into _dl_start_finalFlorian Weimer2024-09-241-2/+2
| | | | | | | | Calling an extern function in a different translation unit before self-relocation is brittle. The compiler may load the address at an earlier point in _dl_start, before self-relocation. In _dl_start_final, the call is behind a compiler barrier, so this cannot happen.
* elf: Eliminate alloca in open_verifyFlorian Weimer2024-09-241-7/+5
| | | | | | With the two-stage approach for exception handling, the name can be freed after it has been copied into the exception, but before it is raised.
* elf: Remove version assert in check_match in elf/dl-lookup.cFlorian Weimer2024-09-243-36/+5
| | | | | | | | | | | | | | This case is detected early in the elf/dl-version.c consistency checks. (These checks could be disabled in the future to allow the removal of symbol versioning from objects.) Commit f0b2132b35 ("ld.so: Support moving versioned symbols between sonames [BZ #24741]) removed another call to _dl_name_match_p. The _dl_check_caller function no longer exists, and the remaining calls to _dl_name_match_p happen under the loader lock. This means that atomic accesses are no longer required for the l_libname list. This supersedes commit 395be7c218 ("elf: Fix data race in _dl_name_match_p [BZ #21349]").
* elf: In rtld_setup_main_map, assume ld.so has a DYNAMIC segmentFlorian Weimer2024-09-241-24/+0
| | | | | The way we build ld.so, it always has a dynamic segment, so checking for its absence is unnecessary.
* misc: Enable internal use of memory protection keysFlorian Weimer2024-09-249-9/+43
| | | | This adds the necessary hidden prototypes.
* misc: Link tst-mkstemp-fuse-parallel with $(shared-thread-library)Florian Weimer2024-09-241-0/+1
| | | | The barrier functions require this on Hurd.
* iconv: Use $(run-program-prefix) for running iconv (bug 32197)Florian Weimer2024-09-241-3/+3
| | | | | | | | | | | With --enable-hardcoded-path-in-tests, $(test-program-prefix) does not redirect to the built glibc, but we need to run iconv (the program) against the built glibc even with --enable-hardcoded-path-in-tests, as it is using the ABI path for the dynamic linker (as an installed program). Use $(run-program-prefix) instead. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* AArch64: Simplify rounding-multiply pattern in several AdvSIMD routinesJoe Ramsay2024-09-235-38/+30
| | | | | | | This operation can be simplified to use simpler multiply-round-convert sequence, which uses fewer instructions and constants. Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
* AArch64: Improve codegen in users of ADVSIMD expm1f helperJoe Ramsay2024-09-234-91/+58
| | | | | | | | Rearrange operations so MOV is not necessary in reduction or around the special-case handler. Reduce memory access by using more indexed MLAs in polynomial. Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
* AArch64: Improve codegen in users of AdvSIMD log1pf helperJoe Ramsay2024-09-235-139/+146
| | | | | | | | | | | | | | | | | | | | log1pf is quite register-intensive - use fewer registers for the polynomial, and make various changes to shorten dependency chains in parent routines. There is now no spilling with GCC 14. Accuracy moves around a little - comments adjusted accordingly but does not require regen-ulps. Use the helper in log1pf as well, instead of having separate implementations. The more accurate polynomial means special-casing can be simplified, and the shorter dependency chain avoids the usual dance around v0, which is otherwise difficult. There is a small duplication of vectors containing 1.0f (or 0x3f800000) - GCC is not currently able to efficiently handle values which fit in FMOV but not MOVI, and are reinterpreted to integer. There may be potential for more optimisation if this is fixed. Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
* AArch64: Improve codegen in SVE F32 logsJoe Ramsay2024-09-233-47/+69
| | | | | | | | | | | Reduce MOVPRFXs by using unpredicated (non-destructive) instructions where possible. Similar to the recent change to AdvSIMD F32 logs, adjust special-case arguments and bounds to allow for more optimal register usage. For all 3 routines one MOVPRFX remains in the reduction, which cannot be avoided as immediate AND and ASR are both destructive. Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
* AArch64: Improve codegen in SVE expf & related routinesJoe Ramsay2024-09-235-148/+136
| | | | | | | | | | | | | | | | | | | | | Reduce MOV and MOVPRFX by improving special-case handling. Use inline helper to duplicate the entire computation between the special- and non-special case branches, removing the contention for z0 between x and the return value. Also rearrange some MLAs and MLSs - by making the multiplicand the destination we can avoid a MOVPRFX in several cases. Also change which constants go in the vector used for lanewise ops - the last lane is no longer wasted. Spotted that shift was incorrect in exp2f and exp10f, w.r.t. to the comment that explains it. Fixed - worst-case ULP for exp2f moves around but it doesn't change significantly for either routine. Worst-case error for coshf increases due to passing x to exp rather than abs(x) - updated the comment, but does not require regen-ulps. Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
* Linux: readdir64_r should not skip d_ino == 0 entries (bug 32126)Florian Weimer2024-09-213-17/+147
| | | | | | | This is the same bug as bug 12165, but for readdir_r. The regression test covers both bug 12165 and bug 32126. Reviewed-by: DJ Delorie <dj@redhat.com>
* dirent: Add tst-rewinddirFlorian Weimer2024-09-212-0/+208
| | | | | | | It verifies that rewinddir allows restarting the directory iteration. Reviewed-by: DJ Delorie <dj@redhat.com>
* dirent: Add tst-readdir-longFlorian Weimer2024-09-212-0/+232
| | | | | | | | It tests long names and ENAMETOOLONG handling, specifically for readdir_r. This is a regression test for bug 14699, bug 32124, and bug 32128. Reviewed-by: DJ Delorie <dj@redhat.com>
* Linux: Use readdir64_r for compat __old_readdir64_r (bug 32128)Florian Weimer2024-09-214-216/+71
| | | | | | | | | | | It is not necessary to do the conversion at the getdents64 layer for readdir64_r. Doing it piecewise for readdir64 is slightly simpler and allows deleting __old_getdents64. This fixes bug 32128 because readdir64_r handles the length check correctly. Reviewed-by: DJ Delorie <dj@redhat.com>
* dirent: Add tst-closedir-leaksFlorian Weimer2024-09-212-0/+97
| | | | | | | It verfies that closedir deallocates memory and closes file descriptors. Reviewed-by: DJ Delorie <dj@redhat.com>
* support: Add valgrind instructions to <support/fuse.h>Florian Weimer2024-09-211-2/+4
| | | | | Replacing an outdated comment (namespace setup is now handled by support_fuse_init).
* support: Fix memory leaks in FUSE testsFlorian Weimer2024-09-212-0/+2
| | | | | The internal read buffer (used by all FUSE tests) was not freed. The support/tst-support_fuse test missed a deallocation.
* misc: FUSE-based tests for mkstempFlorian Weimer2024-09-213-0/+422
| | | | | | | | | | | The tests check that O_EXCL is used properly, that 0600 is used as the mode, that the characters used are as expected, and that the distribution of names generated is reasonably random. The tests run very slowly on some kernel versions, so make them xtests. Reviewed-by: DJ Delorie <dj@redhat.com>
* Add freopen special-case tests: chroot, EFBIG, stdin/stdout/stderrJoseph Myers2024-09-208-0/+385
| | | | | | | | | | | | | | | | | | | | | | | | Add tests of special cases for freopen that were omitted from the more general tests of different modes and similar issues. The special cases in the three tests here are logically unconnected, it was simply convenient to put these tests in one patch. * Test freopen with a NULL path to the new file, in a chroot. Rather than asserting that this fails (logically, failure in this case is an implementation detail; it's not required for freopen to rely on /proc), verify that either it fails (without memory leaks) or that it succeeds and behaves as expected on success. There is no check for file descriptor leaks because the machinery for that also depends on /proc, so can't be used in a chroot. * Test that freopen and freopen64 are genuinely different in configurations with 32-bit off_t by checking for an EFBIG trying to write past 2GB in a file opened with freopen in such a configuration but no error with 64-bit off_t or when opening with freopen64. * Test freopen of stdin, stdout and stderr. Tested for x86_64 and x86.
* Make tst-strtod-underflow type-genericJoseph Myers2024-09-201-60/+297
| | | | | | | | | | | | The test tst-strtod-underflow covers various edge cases close to the underflow threshold for strtod (especially cases where underflow on architectures with after-rounding tininess detection depends on the rounding mode). Make it use the type-generic machinery, with corresponding test inputs for each supported floating-point format, so that other functions in the strtod family are tested for underflow edge cases as well. Tested for x86_64.
* Add tests of more strtod special casesJoseph Myers2024-09-201-0/+14
| | | | | | | | | There is very little test coverage of inputs to strtod-family functions that don't contain anything that can be parsed as a number (one test of ".y" in tst-strtod2), and none that I can see of skipping initial whitespace. Add some tests of these things to tst-strtod2. Tested for x86_64.
* Add more tests of strtod end pointerJoseph Myers2024-09-201-2/+39
| | | | | | | | | Although there are some tests in tst-strtod2 and tst-strtod3 for the end pointer provided by strtod when it doesn't parse the whole string, they aren't very thorough. Add tests of more such cases to tst-strtod2. Tested for x86_64.
* Make tst-strtod2 and tst-strtod5 type-genericJoseph Myers2024-09-202-82/+118
| | | | | | | | | | | | | | Some of the strtod tests use type-generic machinery in tst-strtod.h to test the strto* functions for all floating types, while others only test double even when the tests are in fact meaningful for all floating types. Convert tst-strtod2 and tst-strtod5 to use the type-generic machinery so they test all floating types. I haven't tried to convert them to use newer test interfaces in other ways, just made the changes necessary to use the type-generic machinery. Tested for x86_64.
* Implement run-built-tests=no for make xcheck, always build xtestsFlorian Weimer2024-09-211-6/+11
| | | | | | | | | | | | | | | | | | Previously, the second occurrence of the xtests target expected all xtests to run (as the result of specifying $(xtests)), but these tests have not been run due to the the first xtests target is set up for run-built-tests=no: it only runs tests in $(xtests-special). Consequently, xtests are reported as UNSUPPORTED with “make xcheck run-built-tests=no”. The xtests were not built, either. After this change always, xtests are built regardless of the $(run-built-tests) variable (except for xtests listed in $(tests-unsupported)). To fix the UNSUPPORTED issue, introduce xtests-expected and use that manage test expectations in the second xtests target. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Test that errno is set to 0 at program startupAaron Merey2024-09-202-0/+59
| | | | | | | | | | Add new testcase elf/tst-startup-errno.c which tests that errno is set to 0 at first ELF constructor execution and at the start of the program's main function. Tested for x86_64 Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Add another test for fclose on an unopened fileAaron Merey2024-09-204-3/+69
| | | | | | | | | | | | | | | | | Add new file libio/tst-fclose-unopened2.c that tests whether fclose on an unopened file returns EOF. This test differs from tst-fclose-unopened.c by ensuring the file's buffer is allocated prior to double-fclose. A comment in tst-fclose-unopened.c now clarifies that it is testing a file with an unallocated buffer. Calling fclose on unopened files normally causes a use-after-free bug, however the standard streams are an exception since they are not deallocated by fclose. Tested for x86_64. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* iconv: Input buffering for the iconv program (bug 6050)Florian Weimer2024-09-202-106/+109
| | | | | | Do not read the entire input file into memory. Reviewed-by: DJ Delorie <dj@redhat.com>
* iconv: Multiple - on command line should not fail (bug 32050)Florian Weimer2024-09-202-1/+7
| | | | | | | Usually, the second and subsequent - return EOF immediately and do not contribute to the output, but this is not an error. Reviewed-by: DJ Delorie <dj@redhat.com>
* iconv: Support in-place conversions (bug 10460, bug 32033)Florian Weimer2024-09-204-75/+386
| | | | | | | | | | | | Check if any of the input files overlaps with the output file, and use a temporary file in this case, so that the input is no clobbered before it is read. This fixes bug 10460. It allows to use iconv more easily as a functional replacement for GNU recode. The updated output buffer management truncates the output file if there is no input, fixing bug 32033. Reviewed-by: DJ Delorie <dj@redhat.com>
* iconv: Preserve iconv -c error exit on invalid inputs (bug 32046)Florian Weimer2024-09-2016-108/+280
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In several converters, a __GCONV_ILLEGAL_INPUT result gets overwritten with __GCONV_FULL_OUTPUT. As a result, iconv (the function) returns E2BIG instead of EILSEQ. The iconv program does not see the original EILSEQ failure, does not recognize the invalid input, and may incorrectly exit successfully. To address this, a new __flags bit is used to indicate a sticky input error state. All __GCONV_ILLEGAL_INPUT results are replaced with a function call that sets this new __GCONV_ENCOUNTERED_ILLEGAL_INPUT and returns __GCONV_ILLEGAL_INPUT. The iconv program checks for __GCONV_ENCOUNTERED_ILLEGAL_INPUT and overrides the exit status. The converter changes introducing __gconv_mark_illegal_input are mostly mechanical, except for the res variable initialization in iconvdata/iso-2022-jp.c: this error gets overwritten with __GCONV_OK and other results in the following code. If res == __GCONV_ILLEGAL_INPUT afterwards, STANDARD_TO_LOOP_ERR_HANDLER below will handle it. The __gconv_mark_illegal_input changes do not alter the errno value set by the iconv function. This is simpler to implement than reviewing each __GCONV_FULL_OUTPUT result and adjust it not to override a previous __GCONV_ILLEGAL_INPUT result. Doing it that way would also change some E2BIG errors in to EILSEQ errors, so it had to be done conditionally (under a flag set by the iconv program only), to avoid confusing buffer management in other applications. Reviewed-by: DJ Delorie <dj@redhat.com>
* manual: __is_last is no longer part of iconv internalsFlorian Weimer2024-09-201-9/+9
| | | | | | | | The __is_last field was replaced with a bitmask in commit 85830c4c4688b30d3d76111aa9a26745c7b141d6 in 2000, and multiple bits are in use today. Reviewed-by: DJ Delorie <dj@redhat.com>