[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] ios: avoid collision with O_RDONLY
From: |
David Faust |
Subject: |
[PATCH] ios: avoid collision with O_RDONLY |
Date: |
Fri, 26 Mar 2021 15:41:41 -0700 |
Hi!
ios_dev_file_convert_flags was returning 0 in the case of bad flags.
But, many implementations define the O_RDONLY flag for `open` as 0.
This resulted an unhandled invalid IO flags exception when attempting
to open a file with the 'open' poke builtin and IOS_M_RDONLY.
OK to install? (and probably pick to maint/poke-1?)
2021-03-26 David Faust <david.faust@oracle.com>
* libpoke/ios-dev-file.c (ios_dev_file_convert_flags): Return
-1 for bad flags to avoid collision with O_RDONLY == 0.
(ios_dev_file_open): Update flags_for_open check accordingly.
---
ChangeLog | 6 ++++++
libpoke/ios-dev-file.c | 4 ++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 439daf69..36a1f140 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-03-26 David Faust <david.faust@oracle.com>
+
+ * libpoke/ios-dev-file.c (ios_dev_file_convert_flags): Return
+ -1 for bad flags to avoid collision with O_RDONLY == 0.
+ (ios_dev_file_open): Update flags_for_open check accordingly.
+
2021-03-25 Jose E. Marchesi <jemarch@gnu.org>
* poke/pk-mi-msg.c (pk_mi_set_arg): An ANY msg argument can be of
diff --git a/libpoke/ios-dev-file.c b/libpoke/ios-dev-file.c
index 93d36ff4..94798419 100644
--- a/libpoke/ios-dev-file.c
+++ b/libpoke/ios-dev-file.c
@@ -87,7 +87,7 @@ ios_dev_file_convert_flags (int mode_flags, char
**mode_for_fdopen)
}
else
/* Cannot open a file neither to write nor to read. */
- return 0;
+ return -1;
if (mode_flags & IOS_F_CREATE)
flags_for_open |= O_CREAT;
@@ -112,7 +112,7 @@ ios_dev_file_open (const char *handler, uint64_t flags, int
*error)
/* Decide what mode to use to open the file. */
flags_for_open
= ios_dev_file_convert_flags (mode_flags, &mode_for_fdopen);
- if (flags_for_open == 0)
+ if (flags_for_open == -1)
{
internal_error = IOD_EFLAGS;
goto err;
--
2.31.0
- [PATCH] ios: avoid collision with O_RDONLY,
David Faust <=