OK, [caveat .. I have never seen this code]. Somewhere downstream [pun
unintended :-)] of this code there must be 'something' that will report 'invalid
stream name'. Now, either that can be done right away, or if not (perhaps) you
could substitute a name that will be guaranteed to be treated as invalid later
(null or empty string, perhaps, or something more meaningful). Maybe a poor
later error message, but better than a fix that sometimes could pick up a wrong
file, as Rick worried about?
Those once-in-a-billion chances somehow come around all too often (I blame a
chap called Murphy). :-)
Mike
_____
From: Mark Miesfeld [mailto:[email protected]]
Sent: 28 May 2013 17:44
To: Open Object Rexx Developer Mailing List
Subject: Re: [Oorexx-devel] [bugs:#1177] ooRexx Interpreter Crash
On Tue, May 28, 2013 at 8:42 AM, Mike Cowlishaw <[email protected]> wrote:
I also am a little nervous about the fix, which is the main reason I asked. I'm
going to commit it for now.
No possibility to cause an error/NotReady to be raised (as for an invalid name)?
There is / was no easy way that I saw.
In the first tests I did, prior to trying to write, the stream state is unknown.
Then when you try to actually write to the (truncated) file name, the stream
will be in an error state.
name = 'C:\' || 'bogus'~copies(200)
--fsObj = .Stream~new(copies('x', 999))
fsObj = .Stream~new(name)
say 'Stream state:' fsObj~state
say 'Name: ' fsObj~qualify
fsObj~lineout("Help")
say 'Stream state:' fsObj~state
C:\work.ooRexx>qtest.rex
Stream state: UNKNOWN
Name:
C:\bogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbo
gusbogusbogusbogus
bogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogus
bogusbogusbogusbogusbogusbogusbo
gusbogusbogusbogusbogusbogusbogusbogusbogusbogusb
Stream state: ERROR
C:\work.ooRexx>
But, it is possible to construct a too long string whose truncated name will be
valid.
name = 'C:\work.ooRexx\' || 'bogus'~copies(200)
--fsObj = .Stream~new(copies('x', 999))
fsObj = .Stream~new(name)
say 'Stream state:' fsObj~state
say 'Name: ' fsObj~qualify
fsObj~lineout("Help")
say 'Stream state:' fsObj~state
C:\work.ooRexx>qtest.rex
Stream state: UNKNOWN
Name:
C:\work.ooRexx\bogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogus
bogusbogusbogusbog
usbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbog
usbogusbogusbogusbogusbogusbogus
bogusbogusbogusbogusbogusbogusbogusbogusbogusbogu
Stream state: READY
C:\work.ooRexx>
A problem is that the method currently doesn't return a value:
void SysFileSystem::qualifyStreamName()
and is invoked from a number of different places where the code is not expecting
a return. So there would need to be some significant rewriting for a better
fix.
Where qualifyStreamName is called from StreamNative, the rewrite is pretty
simple and the stream can be put in the error state when the name too long is
detected.
But, where qualifyStreamName is called from the builtin qualify function, the
fix is not so apparent to me. There is no stream to put in an error state that
I see. How do we signal an error there? Should we signal an error? The
truncated name may or may not be a valid file name, but in all cases the
returned truncated value is the longest possible file name on Windows.
--
Mark Miesfeld
------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel