Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2024-08-27
11:23
Merge [22e66b7f413a16ea]: Fix [e155cedf33]: Error-handling in TclGetOpenMode(). check-in: 9d86f86f41 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE
2024-04-11
08:39 • Closed ticket [e155cedf33]: Error-handling in TclGetOpenMode() plus 7 other ... artifact: e723138cbb user: jan.nijtmans
08:35
Fix [e155cedf33]: Error-handling in TclGetOpenMode() check-in: 22e66b7f41 user: jan.nijtmans tags: trunk, main
07:57
Fix [e155cedf33]: Error-handling in TclGetOpenMode(). Add O_ACCMODE fow Windows, in case it is not ... check-in: 68ff52f3c7 user: jan.nijtmans tags: core-8-branch
2024-04-10
16:28 • Ticket [e155cedf33] Error-handling in TclGetOpenMode() status still Open wit... artifact: 55f8e4be58 user: oehhar
14:42 • Ticket [e155cedf33]: 3 changes artifact: a98438c917 user: jan.nijtmans
14:31 • Ticket [e155cedf33]: 4 changes artifact: 0789bde8b7 user: oehhar
13:18
[e155cedf33]: Error-handling in TclGetOpenMode() closed check-in: 1de2bb21a5 user: jan.nijtmans tags: bug-e155cedf33
13:16 • New ticket [e155cedf33] Error-handling in TclGetOpenMode(). artifact: 9dd3c28ecb user: jan.nijtmans

Error-handling in TclGetOpenMode()

Closed / Fixede155cedf33aca13baf5ab0f3749b00861d8924d5Created 3 years agoUpdated 3 years ago
Descriptionwiki2024-04-10 13:16:58
Function TclGetOpenMode() doesn't do much error-handling. For example:
$ tclsh8.6
% open README.md {RDWR RDONLY}
file3
This should be invalid, as `RDWR` and `RDONLY` are incompatible. Also, it doesn't handle repeating:
$ tclsh8.6
% open README.md {RDWR RDWR}
file3

This was noted while working on TIP #691, but since it would make the TIP implementation unneccesary big it's better to separate it.

Referenced by4
oehharwiki2024-04-10 14:31:24

Great, Jan, great action.

I saw your commit: https://core.tcl-lang.org/tcl/info/1de2bb21a5da29a2 -> great action

The unmodified line 1182 of file generic/tclIOCmd.c states:

default:
		Tcl_Panic("Tcl_OpenCmd: invalid mode value");
		break;
	    }

I suppose, this is from old times and should be transfered to an assertion or a real error return. Shall I care?

Take care, Harald

jan.nijtmanswiki2024-04-10 14:42:23

> I suppose, this is from old times ...

In this case, "mode" is produced by the function TclGetOpenModeEx(), and it can only be O_RDONLY, O_WRONLY or O_RDWR. It's impossible to produce another value through user input. Therefore, I think we can keep this Tcl_Panic(): it's impossible to trigger this at script level (neither at C-API level).

oehharwiki2024-04-10 16:28:36

Thanks for the explanation - great !

jan.nijtmanswiki2024-04-11 08:39:32

Fixed [here], present now in core-8-branch and trunk.

It's not really necessary to backport this to 8.6

Log in (anonymous is fine) to add a comment.