Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] musl: backport patch to fix fgetws
@ 2023-08-15 20:35 balejk
  2023-08-17 14:22 ` [PR PATCH] [Updated] " balejk
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: balejk @ 2023-08-15 20:35 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1231 bytes --]

There is a new pull request by balejk against master on the void-packages repository

https://github.com/balejk/void-packages musl-fgetws
https://github.com/void-linux/void-packages/pull/45617

musl: backport patch to fix fgetws
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
#### Local build testing
- I built this PR locally for my native architecture, (x86_64-musl)
<!--
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/45617.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-musl-fgetws-45617.patch --]
[-- Type: text/x-diff, Size: 2992 bytes --]

From 3f0d038d68e6418a5329eb504479f00225f88e61 Mon Sep 17 00:00:00 2001
From: Karel Balej <balejk@matfyz.cz>
Date: Tue, 15 Aug 2023 22:21:18 +0200
Subject: [PATCH] musl: backport patch to fix fgetws

---
 srcpkgs/musl/patches/fgetws.patch | 55 +++++++++++++++++++++++++++++++
 srcpkgs/musl/template             |  2 +-
 2 files changed, 56 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/musl/patches/fgetws.patch

diff --git a/srcpkgs/musl/patches/fgetws.patch b/srcpkgs/musl/patches/fgetws.patch
new file mode 100644
index 0000000000000..86354f918a5ca
--- /dev/null
+++ b/srcpkgs/musl/patches/fgetws.patch
@@ -0,0 +1,55 @@
+commit f8bdc3048216f41eaaf655524fa286cfb1184a70
+Author: Rich Felker <dalias@aerifal.cx>
+Date:   Sun Feb 20 20:11:14 2022 -0500
+
+    fix spurious failures by fgetws when buffer ends with partial character
+    
+    commit a90d9da1d1b14d81c4f93e1a6d1a686c3312e4ba made fgetws look for
+    changes to errno by fgetwc to detect encoding errors, since ISO C did
+    not allow the implementation to set the stream's error flag in this
+    case, and the fgetwc interface did not admit any other way to detect
+    the error. however, the possibility of fgetwc setting errno to EILSEQ
+    in the success path was overlooked, and in fact this can happen if the
+    buffer ends with a partial character, causing mbtowc to be called with
+    only part of the character available.
+    
+    since that change was made, the C standard was amended to specify that
+    fgetwc set the stream error flag on encoding errors, and commit
+    511d70738bce11a67219d0132ce725c323d00e4e made it do so. thus, there is
+    no longer any need for fgetws to poke at errno to handle encoding
+    errors.
+    
+    this commit reverts commit a90d9da1d1b14d81c4f93e1a6d1a686c3312e4ba
+    and thereby fixes the problem.
+
+diff --git a/src/stdio/fgetws.c b/src/stdio/fgetws.c
+index b08b3049..195cb435 100644
+--- a/src/stdio/fgetws.c
++++ b/src/stdio/fgetws.c
+@@ -1,6 +1,5 @@
+ #include "stdio_impl.h"
+ #include <wchar.h>
+-#include <errno.h>
+ 
+ wint_t __fgetwc_unlocked(FILE *);
+ 
+@@ -12,10 +11,6 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
+ 
+ 	FLOCK(f);
+ 
+-	/* Setup a dummy errno so we can detect EILSEQ. This is
+-	 * the only way to catch encoding errors in the form of a
+-	 * partial character just before EOF. */
+-	errno = EAGAIN;
+ 	for (; n; n--) {
+ 		wint_t c = __fgetwc_unlocked(f);
+ 		if (c == WEOF) break;
+@@ -23,7 +18,7 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
+ 		if (c == '\n') break;
+ 	}
+ 	*p = 0;
+-	if (ferror(f) || errno==EILSEQ) p = s;
++	if (ferror(f)) p = s;
+ 
+ 	FUNLOCK(f);
+ 
diff --git a/srcpkgs/musl/template b/srcpkgs/musl/template
index e0e05c2df0995..6c98fac0962e9 100644
--- a/srcpkgs/musl/template
+++ b/srcpkgs/musl/template
@@ -2,7 +2,7 @@
 pkgname=musl
 reverts="1.2.0_1"
 version=1.1.24
-revision=17
+revision=18
 archs="*-musl"
 bootstrap=yes
 build_style=gnu-configure

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PR PATCH] [Updated] musl: backport patch to fix fgetws
  2023-08-15 20:35 [PR PATCH] musl: backport patch to fix fgetws balejk
@ 2023-08-17 14:22 ` balejk
  2023-08-30 17:36 ` balejk
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: balejk @ 2023-08-17 14:22 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

There is an updated pull request by balejk against master on the void-packages repository

https://github.com/balejk/void-packages musl-fgetws
https://github.com/void-linux/void-packages/pull/45617

musl: backport patch to fix fgetws
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
#### Local build testing
- I built this PR locally for my native architecture, (x86_64-musl)
<!--
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/45617.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-musl-fgetws-45617.patch --]
[-- Type: text/x-diff, Size: 3055 bytes --]

From b636ea4aca0d63e7e2f738916bcaea549ccd76cf Mon Sep 17 00:00:00 2001
From: Karel Balej <balejk@matfyz.cz>
Date: Tue, 15 Aug 2023 22:21:18 +0200
Subject: [PATCH] musl: backport patch to fix fgetws

---
 srcpkgs/musl/patches/fgetws.patch | 61 +++++++++++++++++++++++++++++++
 srcpkgs/musl/template             |  2 +-
 2 files changed, 62 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/musl/patches/fgetws.patch

diff --git a/srcpkgs/musl/patches/fgetws.patch b/srcpkgs/musl/patches/fgetws.patch
new file mode 100644
index 0000000000000..c85c874279eab
--- /dev/null
+++ b/srcpkgs/musl/patches/fgetws.patch
@@ -0,0 +1,61 @@
+From f8bdc3048216f41eaaf655524fa286cfb1184a70 Mon Sep 17 00:00:00 2001
+From: Rich Felker <dalias@aerifal.cx>
+Date: Sun, 20 Feb 2022 20:11:14 -0500
+Subject: [PATCH] fix spurious failures by fgetws when buffer ends with partial
+ character
+
+commit a90d9da1d1b14d81c4f93e1a6d1a686c3312e4ba made fgetws look for
+changes to errno by fgetwc to detect encoding errors, since ISO C did
+not allow the implementation to set the stream's error flag in this
+case, and the fgetwc interface did not admit any other way to detect
+the error. however, the possibility of fgetwc setting errno to EILSEQ
+in the success path was overlooked, and in fact this can happen if the
+buffer ends with a partial character, causing mbtowc to be called with
+only part of the character available.
+
+since that change was made, the C standard was amended to specify that
+fgetwc set the stream error flag on encoding errors, and commit
+511d70738bce11a67219d0132ce725c323d00e4e made it do so. thus, there is
+no longer any need for fgetws to poke at errno to handle encoding
+errors.
+
+this commit reverts commit a90d9da1d1b14d81c4f93e1a6d1a686c3312e4ba
+and thereby fixes the problem.
+---
+ src/stdio/fgetws.c | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/stdio/fgetws.c b/src/stdio/fgetws.c
+index b08b3049..195cb435 100644
+--- a/src/stdio/fgetws.c
++++ b/src/stdio/fgetws.c
+@@ -1,6 +1,5 @@
+ #include "stdio_impl.h"
+ #include <wchar.h>
+-#include <errno.h>
+ 
+ wint_t __fgetwc_unlocked(FILE *);
+ 
+@@ -12,10 +11,6 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
+ 
+ 	FLOCK(f);
+ 
+-	/* Setup a dummy errno so we can detect EILSEQ. This is
+-	 * the only way to catch encoding errors in the form of a
+-	 * partial character just before EOF. */
+-	errno = EAGAIN;
+ 	for (; n; n--) {
+ 		wint_t c = __fgetwc_unlocked(f);
+ 		if (c == WEOF) break;
+@@ -23,7 +18,7 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
+ 		if (c == '\n') break;
+ 	}
+ 	*p = 0;
+-	if (ferror(f) || errno==EILSEQ) p = s;
++	if (ferror(f)) p = s;
+ 
+ 	FUNLOCK(f);
+ 
+-- 
+2.41.0
+
diff --git a/srcpkgs/musl/template b/srcpkgs/musl/template
index e0e05c2df0995..6c98fac0962e9 100644
--- a/srcpkgs/musl/template
+++ b/srcpkgs/musl/template
@@ -2,7 +2,7 @@
 pkgname=musl
 reverts="1.2.0_1"
 version=1.1.24
-revision=17
+revision=18
 archs="*-musl"
 bootstrap=yes
 build_style=gnu-configure

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PR PATCH] [Updated] musl: backport patch to fix fgetws
  2023-08-15 20:35 [PR PATCH] musl: backport patch to fix fgetws balejk
  2023-08-17 14:22 ` [PR PATCH] [Updated] " balejk
@ 2023-08-30 17:36 ` balejk
  2023-09-10 10:52 ` balejk
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: balejk @ 2023-08-30 17:36 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

There is an updated pull request by balejk against master on the void-packages repository

https://github.com/balejk/void-packages musl-fgetws
https://github.com/void-linux/void-packages/pull/45617

musl: backport patch to fix fgetws
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
#### Local build testing
- I built this PR locally for my native architecture, (x86_64-musl)
<!--
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/45617.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-musl-fgetws-45617.patch --]
[-- Type: text/x-diff, Size: 3055 bytes --]

From a8420d6d0fdf98b5a4bb87dfb4e676b3e6cc7d0a Mon Sep 17 00:00:00 2001
From: Karel Balej <balejk@matfyz.cz>
Date: Tue, 15 Aug 2023 22:21:18 +0200
Subject: [PATCH] musl: backport patch to fix fgetws

---
 srcpkgs/musl/patches/fgetws.patch | 61 +++++++++++++++++++++++++++++++
 srcpkgs/musl/template             |  2 +-
 2 files changed, 62 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/musl/patches/fgetws.patch

diff --git a/srcpkgs/musl/patches/fgetws.patch b/srcpkgs/musl/patches/fgetws.patch
new file mode 100644
index 0000000000000..c85c874279eab
--- /dev/null
+++ b/srcpkgs/musl/patches/fgetws.patch
@@ -0,0 +1,61 @@
+From f8bdc3048216f41eaaf655524fa286cfb1184a70 Mon Sep 17 00:00:00 2001
+From: Rich Felker <dalias@aerifal.cx>
+Date: Sun, 20 Feb 2022 20:11:14 -0500
+Subject: [PATCH] fix spurious failures by fgetws when buffer ends with partial
+ character
+
+commit a90d9da1d1b14d81c4f93e1a6d1a686c3312e4ba made fgetws look for
+changes to errno by fgetwc to detect encoding errors, since ISO C did
+not allow the implementation to set the stream's error flag in this
+case, and the fgetwc interface did not admit any other way to detect
+the error. however, the possibility of fgetwc setting errno to EILSEQ
+in the success path was overlooked, and in fact this can happen if the
+buffer ends with a partial character, causing mbtowc to be called with
+only part of the character available.
+
+since that change was made, the C standard was amended to specify that
+fgetwc set the stream error flag on encoding errors, and commit
+511d70738bce11a67219d0132ce725c323d00e4e made it do so. thus, there is
+no longer any need for fgetws to poke at errno to handle encoding
+errors.
+
+this commit reverts commit a90d9da1d1b14d81c4f93e1a6d1a686c3312e4ba
+and thereby fixes the problem.
+---
+ src/stdio/fgetws.c | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/stdio/fgetws.c b/src/stdio/fgetws.c
+index b08b3049..195cb435 100644
+--- a/src/stdio/fgetws.c
++++ b/src/stdio/fgetws.c
+@@ -1,6 +1,5 @@
+ #include "stdio_impl.h"
+ #include <wchar.h>
+-#include <errno.h>
+ 
+ wint_t __fgetwc_unlocked(FILE *);
+ 
+@@ -12,10 +11,6 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
+ 
+ 	FLOCK(f);
+ 
+-	/* Setup a dummy errno so we can detect EILSEQ. This is
+-	 * the only way to catch encoding errors in the form of a
+-	 * partial character just before EOF. */
+-	errno = EAGAIN;
+ 	for (; n; n--) {
+ 		wint_t c = __fgetwc_unlocked(f);
+ 		if (c == WEOF) break;
+@@ -23,7 +18,7 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
+ 		if (c == '\n') break;
+ 	}
+ 	*p = 0;
+-	if (ferror(f) || errno==EILSEQ) p = s;
++	if (ferror(f)) p = s;
+ 
+ 	FUNLOCK(f);
+ 
+-- 
+2.41.0
+
diff --git a/srcpkgs/musl/template b/srcpkgs/musl/template
index 6c98fac0962e9..9838f9ad9e613 100644
--- a/srcpkgs/musl/template
+++ b/srcpkgs/musl/template
@@ -2,7 +2,7 @@
 pkgname=musl
 reverts="1.2.0_1"
 version=1.1.24
-revision=18
+revision=19
 archs="*-musl"
 bootstrap=yes
 build_style=gnu-configure

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PR PATCH] [Updated] musl: backport patch to fix fgetws
  2023-08-15 20:35 [PR PATCH] musl: backport patch to fix fgetws balejk
  2023-08-17 14:22 ` [PR PATCH] [Updated] " balejk
  2023-08-30 17:36 ` balejk
@ 2023-09-10 10:52 ` balejk
  2023-12-10  1:48 ` github-actions
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: balejk @ 2023-09-10 10:52 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

There is an updated pull request by balejk against master on the void-packages repository

https://github.com/balejk/void-packages musl-fgetws
https://github.com/void-linux/void-packages/pull/45617

musl: backport patch to fix fgetws
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
#### Local build testing
- I built this PR locally for my native architecture, (x86_64-musl)
<!--
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/45617.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-musl-fgetws-45617.patch --]
[-- Type: text/x-diff, Size: 3055 bytes --]

From d1a8d1698c6be8ab35f07d5e1eb164d87ea3a3bf Mon Sep 17 00:00:00 2001
From: Karel Balej <balejk@matfyz.cz>
Date: Tue, 15 Aug 2023 22:21:18 +0200
Subject: [PATCH] musl: backport patch to fix fgetws

---
 srcpkgs/musl/patches/fgetws.patch | 61 +++++++++++++++++++++++++++++++
 srcpkgs/musl/template             |  2 +-
 2 files changed, 62 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/musl/patches/fgetws.patch

diff --git a/srcpkgs/musl/patches/fgetws.patch b/srcpkgs/musl/patches/fgetws.patch
new file mode 100644
index 0000000000000..c85c874279eab
--- /dev/null
+++ b/srcpkgs/musl/patches/fgetws.patch
@@ -0,0 +1,61 @@
+From f8bdc3048216f41eaaf655524fa286cfb1184a70 Mon Sep 17 00:00:00 2001
+From: Rich Felker <dalias@aerifal.cx>
+Date: Sun, 20 Feb 2022 20:11:14 -0500
+Subject: [PATCH] fix spurious failures by fgetws when buffer ends with partial
+ character
+
+commit a90d9da1d1b14d81c4f93e1a6d1a686c3312e4ba made fgetws look for
+changes to errno by fgetwc to detect encoding errors, since ISO C did
+not allow the implementation to set the stream's error flag in this
+case, and the fgetwc interface did not admit any other way to detect
+the error. however, the possibility of fgetwc setting errno to EILSEQ
+in the success path was overlooked, and in fact this can happen if the
+buffer ends with a partial character, causing mbtowc to be called with
+only part of the character available.
+
+since that change was made, the C standard was amended to specify that
+fgetwc set the stream error flag on encoding errors, and commit
+511d70738bce11a67219d0132ce725c323d00e4e made it do so. thus, there is
+no longer any need for fgetws to poke at errno to handle encoding
+errors.
+
+this commit reverts commit a90d9da1d1b14d81c4f93e1a6d1a686c3312e4ba
+and thereby fixes the problem.
+---
+ src/stdio/fgetws.c | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/stdio/fgetws.c b/src/stdio/fgetws.c
+index b08b3049..195cb435 100644
+--- a/src/stdio/fgetws.c
++++ b/src/stdio/fgetws.c
+@@ -1,6 +1,5 @@
+ #include "stdio_impl.h"
+ #include <wchar.h>
+-#include <errno.h>
+ 
+ wint_t __fgetwc_unlocked(FILE *);
+ 
+@@ -12,10 +11,6 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
+ 
+ 	FLOCK(f);
+ 
+-	/* Setup a dummy errno so we can detect EILSEQ. This is
+-	 * the only way to catch encoding errors in the form of a
+-	 * partial character just before EOF. */
+-	errno = EAGAIN;
+ 	for (; n; n--) {
+ 		wint_t c = __fgetwc_unlocked(f);
+ 		if (c == WEOF) break;
+@@ -23,7 +18,7 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
+ 		if (c == '\n') break;
+ 	}
+ 	*p = 0;
+-	if (ferror(f) || errno==EILSEQ) p = s;
++	if (ferror(f)) p = s;
+ 
+ 	FUNLOCK(f);
+ 
+-- 
+2.41.0
+
diff --git a/srcpkgs/musl/template b/srcpkgs/musl/template
index 6c98fac0962e9..9838f9ad9e613 100644
--- a/srcpkgs/musl/template
+++ b/srcpkgs/musl/template
@@ -2,7 +2,7 @@
 pkgname=musl
 reverts="1.2.0_1"
 version=1.1.24
-revision=18
+revision=19
 archs="*-musl"
 bootstrap=yes
 build_style=gnu-configure

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: musl: backport patch to fix fgetws
  2023-08-15 20:35 [PR PATCH] musl: backport patch to fix fgetws balejk
                   ` (2 preceding siblings ...)
  2023-09-10 10:52 ` balejk
@ 2023-12-10  1:48 ` github-actions
  2023-12-15 20:31 ` balejk
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: github-actions @ 2023-12-10  1:48 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 305 bytes --]

New comment by github-actions[bot] on void-packages repository

https://github.com/void-linux/void-packages/pull/45617#issuecomment-1848829125

Comment:
Pull Requests become stale 90 days after last activity and are closed 14 days after that.  If this pull request is still relevant bump it or assign it.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: musl: backport patch to fix fgetws
  2023-08-15 20:35 [PR PATCH] musl: backport patch to fix fgetws balejk
                   ` (3 preceding siblings ...)
  2023-12-10  1:48 ` github-actions
@ 2023-12-15 20:31 ` balejk
  2024-01-13 17:37 ` [PR PATCH] [Updated] " balejk
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: balejk @ 2023-12-15 20:31 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2873 bytes --]

New comment by balejk on void-packages repository

https://github.com/void-linux/void-packages/pull/45617#issuecomment-1858452021

Comment:
This is not stale, I can still reproduce the issue.

To add some context, I discovered this when running aerc's test suite, which
also tests a C program for wrapping emails. This test failed because the
program only wrapped part of the text and stripped the rest because fgetws did
not correctly recognize EOF.

Below is a minimal working example along with the test text courtesy of aerc:
```c
#include <stdio.h>
#include <wchar.h>
#include <stdbool.h>
#include <locale.h>

#define BUFFER_SIZE 8192

int main() {
	FILE *in = fopen("mwe.in", "r");
	wchar_t buf[BUFFER_SIZE];
	setlocale(LC_ALL, "");
	while (fgetws(buf, BUFFER_SIZE, in)) {
		fwprintf(stdout, buf);
	}
	fclose(in);
	return 0;
}
```
```
Λορεμ ιπσθμ δολορ σιτ αμετ, ρεβθμ φαλλι γραεcισ θτ θσθ, θσθ ομνισ μοδθσ ατομορθμ ει, δθο εραντ πραεσεντ νο. Εξ εθμ μολεστιαε ιντελλεγαμ, σεα λαβιτθρ αλιενθμ τε. Θσθ αν τεμπορ φορενσιβθσ, σιτ διcτα διcερετ ποσιδονιθμ ατ. Σενσεριτ δισσεντιθντ ει μελ, φεθγιατ πλαcερατ περ cθ. Εα σιτ μοδθσ νονθμυ μελιορε, ιντεγρε θλλαμcορπερ νε cθμ. Εα νεc σαεπε μανδαμθσ, qθισ vολθπτθα cονσθλατθ νο vελ. Ηισ cθ νεμορε ποσσιμ.

Αν προ φαcερ αργθμεντθμ, ατ μαλορθμ ιμπερδιετ ιντελλεγαμ θσθ, αδ πρι λθcιλιθσ σcριπσεριτ. Θσθ ιν σολθμ διcατ δεμοcριτθμ, σιμθλ σcριπσεριτ εθ μει, vιξ εξ ειρμοδ αccθσατα. Qθι ιμπεδιτ cοπιοσαε ιμπερδιετ εα, αφφερτ ορνατθσ ηισ εθ, αεqθε τολλιτ cονσεcτετθερ νε προ! Ιπσθμ σεντεντιαε ετ προ, αθτεμ σθαvιτατε cονστιτθαμ εξ qθι? Ταντασ λεγερε qθι ιδ?

Θσθ νισλ νιηιλ ηενδρεριτ τε! Ιπσθμ νθσqθαμ ιθσ εξ? Ηισ αν ιπσθμ λατινε δισσεντιθντ. Vιμ αλιqθιδ τεμποριβθσ vολθπτατιβθσ αδ, αδ πρι δομινγ απεριρι δισπθτατιονι. Vιμ σθμμο αφφερτ εα, νονθμυ ποσσιτ φαβθλασ ατ εστ.
```

Save the above text as `mwe.in` and execute the above program within the same directory. Only part of the text will get printed back.

This could potentially lead to some information loss for people who use this program (`wrap`) with aerc on musl because it could strip out part of a received message while wrapping it.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PR PATCH] [Updated] musl: backport patch to fix fgetws
  2023-08-15 20:35 [PR PATCH] musl: backport patch to fix fgetws balejk
                   ` (4 preceding siblings ...)
  2023-12-15 20:31 ` balejk
@ 2024-01-13 17:37 ` balejk
  2024-04-13  1:39 ` github-actions
  2024-04-27  1:45 ` [PR PATCH] [Closed]: " github-actions
  7 siblings, 0 replies; 9+ messages in thread
From: balejk @ 2024-01-13 17:37 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

There is an updated pull request by balejk against master on the void-packages repository

https://github.com/balejk/void-packages musl-fgetws
https://github.com/void-linux/void-packages/pull/45617

musl: backport patch to fix fgetws
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
#### Local build testing
- I built this PR locally for my native architecture, (x86_64-musl)
<!--
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/45617.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-musl-fgetws-45617.patch --]
[-- Type: text/x-diff, Size: 3055 bytes --]

From f3069957b521044f40e99e62a4a147eb4e68afed Mon Sep 17 00:00:00 2001
From: Karel Balej <balejk@matfyz.cz>
Date: Tue, 15 Aug 2023 22:21:18 +0200
Subject: [PATCH] musl: backport patch to fix fgetws

---
 srcpkgs/musl/patches/fgetws.patch | 61 +++++++++++++++++++++++++++++++
 srcpkgs/musl/template             |  2 +-
 2 files changed, 62 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/musl/patches/fgetws.patch

diff --git a/srcpkgs/musl/patches/fgetws.patch b/srcpkgs/musl/patches/fgetws.patch
new file mode 100644
index 0000000000000..c85c874279eab
--- /dev/null
+++ b/srcpkgs/musl/patches/fgetws.patch
@@ -0,0 +1,61 @@
+From f8bdc3048216f41eaaf655524fa286cfb1184a70 Mon Sep 17 00:00:00 2001
+From: Rich Felker <dalias@aerifal.cx>
+Date: Sun, 20 Feb 2022 20:11:14 -0500
+Subject: [PATCH] fix spurious failures by fgetws when buffer ends with partial
+ character
+
+commit a90d9da1d1b14d81c4f93e1a6d1a686c3312e4ba made fgetws look for
+changes to errno by fgetwc to detect encoding errors, since ISO C did
+not allow the implementation to set the stream's error flag in this
+case, and the fgetwc interface did not admit any other way to detect
+the error. however, the possibility of fgetwc setting errno to EILSEQ
+in the success path was overlooked, and in fact this can happen if the
+buffer ends with a partial character, causing mbtowc to be called with
+only part of the character available.
+
+since that change was made, the C standard was amended to specify that
+fgetwc set the stream error flag on encoding errors, and commit
+511d70738bce11a67219d0132ce725c323d00e4e made it do so. thus, there is
+no longer any need for fgetws to poke at errno to handle encoding
+errors.
+
+this commit reverts commit a90d9da1d1b14d81c4f93e1a6d1a686c3312e4ba
+and thereby fixes the problem.
+---
+ src/stdio/fgetws.c | 7 +------
+ 1 file changed, 1 insertion(+), 6 deletions(-)
+
+diff --git a/src/stdio/fgetws.c b/src/stdio/fgetws.c
+index b08b3049..195cb435 100644
+--- a/src/stdio/fgetws.c
++++ b/src/stdio/fgetws.c
+@@ -1,6 +1,5 @@
+ #include "stdio_impl.h"
+ #include <wchar.h>
+-#include <errno.h>
+ 
+ wint_t __fgetwc_unlocked(FILE *);
+ 
+@@ -12,10 +11,6 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
+ 
+ 	FLOCK(f);
+ 
+-	/* Setup a dummy errno so we can detect EILSEQ. This is
+-	 * the only way to catch encoding errors in the form of a
+-	 * partial character just before EOF. */
+-	errno = EAGAIN;
+ 	for (; n; n--) {
+ 		wint_t c = __fgetwc_unlocked(f);
+ 		if (c == WEOF) break;
+@@ -23,7 +18,7 @@ wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
+ 		if (c == '\n') break;
+ 	}
+ 	*p = 0;
+-	if (ferror(f) || errno==EILSEQ) p = s;
++	if (ferror(f)) p = s;
+ 
+ 	FUNLOCK(f);
+ 
+-- 
+2.41.0
+
diff --git a/srcpkgs/musl/template b/srcpkgs/musl/template
index 9838f9ad9e613..8c3be7d76e8a1 100644
--- a/srcpkgs/musl/template
+++ b/srcpkgs/musl/template
@@ -2,7 +2,7 @@
 pkgname=musl
 reverts="1.2.0_1"
 version=1.1.24
-revision=19
+revision=20
 archs="*-musl"
 bootstrap=yes
 build_style=gnu-configure

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: musl: backport patch to fix fgetws
  2023-08-15 20:35 [PR PATCH] musl: backport patch to fix fgetws balejk
                   ` (5 preceding siblings ...)
  2024-01-13 17:37 ` [PR PATCH] [Updated] " balejk
@ 2024-04-13  1:39 ` github-actions
  2024-04-27  1:45 ` [PR PATCH] [Closed]: " github-actions
  7 siblings, 0 replies; 9+ messages in thread
From: github-actions @ 2024-04-13  1:39 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 305 bytes --]

New comment by github-actions[bot] on void-packages repository

https://github.com/void-linux/void-packages/pull/45617#issuecomment-2052915532

Comment:
Pull Requests become stale 90 days after last activity and are closed 14 days after that.  If this pull request is still relevant bump it or assign it.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PR PATCH] [Closed]: musl: backport patch to fix fgetws
  2023-08-15 20:35 [PR PATCH] musl: backport patch to fix fgetws balejk
                   ` (6 preceding siblings ...)
  2024-04-13  1:39 ` github-actions
@ 2024-04-27  1:45 ` github-actions
  7 siblings, 0 replies; 9+ messages in thread
From: github-actions @ 2024-04-27  1:45 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1078 bytes --]

There's a closed pull request on the void-packages repository

musl: backport patch to fix fgetws
https://github.com/void-linux/void-packages/pull/45617

Description:
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
#### Local build testing
- I built this PR locally for my native architecture, (x86_64-musl)
<!--
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-04-27  1:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-15 20:35 [PR PATCH] musl: backport patch to fix fgetws balejk
2023-08-17 14:22 ` [PR PATCH] [Updated] " balejk
2023-08-30 17:36 ` balejk
2023-09-10 10:52 ` balejk
2023-12-10  1:48 ` github-actions
2023-12-15 20:31 ` balejk
2024-01-13 17:37 ` [PR PATCH] [Updated] " balejk
2024-04-13  1:39 ` github-actions
2024-04-27  1:45 ` [PR PATCH] [Closed]: " github-actions

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).