On Tue, May 28, 2013 at 11:55 AM, Mike Cowlishaw <[email protected]>wrote:

> **
> 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
>

In the Unix version, if the name is too long for the receiving buffer, the
return value is set to the empty string:

void SysFileSystem::qualifyStreamName(
  const char *name,                   // input name
  char *fullName,                     // the output name
  size_t bufferSize)                  // size of the output buffer
/*******************************************************************/
/* Function:  Qualify a stream name for this system                */
/*******************************************************************/
{
    char tempPath[MaximumFileNameBuffer];// temp store

    /* already expanded? */
    if (*fullName != '\0')
    {
        return;           /* nothing more to do                */
    }

    strcpy(tempPath, name);
    bool done = SysFileSystem::canonicalizeName(tempPath);
    if (done && *strlen(tempPath) < bufferSize*)
    {
        strcpy(fullName, tempPath);
    }
    else
    {
       * fullName[0] = '\0'*; // or leave it unchanged ?
    }
    return;
}


Unfortunately that is too late to check the length because if the length is
too long for tempPath, then it has already seg faulted.

So, what if I check the length earlier and just return the empty string if
the input name is too long?  (In both Windows and Unix.)  Is that
acceptable to every one?

--
Mark Miesfeld
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to