summaryrefslogtreecommitdiff
path: root/test/locale/collate-test.c
diff options
context:
space:
mode:
authorJan Vangorp <jan.vangorp_ext@softathome.com>2016-06-09 00:00:18 +0200
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2016-06-12 11:44:45 +0200
commit568ceebf6adfc58c64a95133311268db626cdec2 (patch)
tree0e39be51e840fac004596aec34c0de6c5c3f4f59 /test/locale/collate-test.c
parent0f541b5c48b7b0df80e2aaa8fdbf653a8b8bcd03 (diff)
Fix infinite loop when fopencookie custom write returns 0 on error
The man page for fopencookie prescribes that custom write functions should return 0 on error (and should definitely not return a negative value) [1]. However, the uClibc implementation expects a negative return value in case of an error (libc/stdio/_WRITE.c). If the write function returns 0 on error, we drop into an infinite loop if the error persists. This patch wraps the user supplied write function such that a 0 return value is converted to -1. errno is first set to EAGAIN such that if the custom write function does not set errno in case of error, this is treated as a "soft" error. Custom write functions that cater towards uClibc and _do_ return a negative value are not affected. If no custom write function is supplied, set errno to EINVAL such that this condition is treated as a "hard" error. Previously the behaviour depended on whether the last error before the write happened to be a "hard" or a "soft" error. [1] http://git.kernel.org/cgit/docs/man-pages/man-pages.git/tree/man3/fopencookie.3?id=6c0d0ef0c7a9c4bcf805c6f9e9bc1ef1c3865ea0#n164 Signed-off-by: Jan Vangorp <jan.vangorp_ext@softathome.com>
Diffstat (limited to 'test/locale/collate-test.c')
0 files changed, 0 insertions, 0 deletions