fileops: Don't process , ccs= as individual mode flags (BZ#18906)
Checks
Context |
Check |
Description |
redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
redhat-pt-bot/TryBot-32bit |
fail
|
Patch caused testsuite regressions
|
linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-arm |
fail
|
Testing failed
|
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
fail
|
Testing failed
|
Commit Message
In processing the first 7 individual characters of the mode for fopen
if ,ccs= is used those characters will be processed as well. Stop
processing individual mode flags once a comma is encountered. This has
the effect of requiring ,ccs= to be the last mode flag in the mode
string. Add a testcase to check that the ,ccs= mode flag is not
processed as individual mode flags.
---
libio/fileops.c | 1 +
libio/tst-fopenloc.c | 30 +++++++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 1 deletion(-)
Comments
On Thu, Jun 15, 2023 at 08:54:24AM -0400, Joe Simmons-Talbott wrote:
> In processing the first 7 individual characters of the mode for fopen
> if ,ccs= is used those characters will be processed as well. Stop
> processing individual mode flags once a comma is encountered. This has
> the effect of requiring ,ccs= to be the last mode flag in the mode
> string. Add a testcase to check that the ,ccs= mode flag is not
> processed as individual mode flags.
There was a memory leak in the testcase in this version. Fixed in v2.
Thanks,
Joe
@@ -247,6 +247,7 @@ _IO_new_file_fopen (FILE *fp, const char *filename, const char *mode,
switch (*++mode)
{
case '\0':
+ case ',':
break;
case '+':
omode = O_RDWR;
@@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#include <errno.h>
+#include <fcntl.h>
#include <locale.h>
#include <mcheck.h>
#include <stdio.h>
@@ -24,6 +25,7 @@
#include <string.h>
#include <wchar.h>
#include <sys/resource.h>
+#include <support/check.h>
#include <support/support.h>
#include <support/xstdio.h>
@@ -55,6 +57,29 @@ do_bz17916 (void)
return 0;
}
+static int
+do_bz18906 (void)
+{
+ /* BZ #18906 -- check processing of ,ccs= as flags case. */
+
+ const char *ccs = "r,ccs=+ISO-8859-1";
+ size_t retval;
+
+ FILE *fp = fopen (inputfile, ccs);
+ int flags;
+
+ TEST_VERIFY(fp != NULL);
+
+ if (fp != NULL)
+ {
+ flags = fcntl(fileno(fp), F_GETFL);
+ retval = (flags & O_RDWR) | (flags & O_WRONLY);
+ TEST_COMPARE(retval, false);
+ }
+
+ return EXIT_SUCCESS;
+}
+
static int
do_test (void)
{
@@ -78,7 +103,10 @@ do_test (void)
xfclose (fp);
- return do_bz17916 ();
+ TEST_COMPARE(do_bz17916 (), 0);
+ TEST_COMPARE(do_bz18906 (), 0);
+
+ return EXIT_SUCCESS;
}
#include <support/test-driver.c>