public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Possible error in cygpath
@ 2002-05-14  8:27 Mark Blackburn
  2002-05-14  9:39 ` Corinna Vinschen
  0 siblings, 1 reply; 13+ messages in thread
From: Mark Blackburn @ 2002-05-14  8:27 UTC (permalink / raw)
  To: cygwin

In cygpath.cc there is a function that goes like this:

static char *
get_short_name (const char *filename)
{
  char *sbuf;
  DWORD len = GetShortPathName (filename, NULL, 0);
  if (len == ERROR_INVALID_PARAMETER)
    {
      fprintf (stderr, "%s: cannot create short name of %s\n", prog_name,
	       filename);
      exit (2);
    }
  sbuf = (char *) malloc (++len);
  if (sbuf == NULL)
    {
      fprintf (stderr, "%s: out of memory\n", prog_name);
      exit (1);
    }
  if (GetShortPathName (filename, sbuf, len) == ERROR_INVALID_PARAMETER)
    {
      fprintf (stderr, "%s: cannot create short name of %s\n", prog_name,
	       filename);
      exit (2);
    }
  fprintf(stderr, "get_short_name: sbuf=%s\n",sbuf);
  return sbuf;
}


The spot where it says:
  DWORD len = GetShortPathName (filename, NULL, 0);
  if (len == ERROR_INVALID_PARAMETER)

is what worries me, I think it should be a little more like:
  DWORD len = GetShortPathName (filename, NULL, 0);
  if (len == 0 && GetLastError() == ERROR_INVALID_PARAMETER)

I don't know how this problem might manifest itself though I suspect that
if GetShortPathName returns a length of 87 then bad things might happen 
( 87 The parameter is incorrect. ERROR_INVALID_PARAMETER).

By the way I noticed this while I was trying to add a -l option to cygpath
which is similar to the -s option but it will convert a muddled 8.3 name
like PROGRA~1 to "Program Files" and I want to know if anyone else might
have been working on that.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 13+ messages in thread
* RE: Possible error in cygpath
@ 2002-05-15  4:39 Schaible, Jorg
  2002-05-15  5:38 ` Corinna Vinschen
  2002-05-15 14:21 ` Sam Edge
  0 siblings, 2 replies; 13+ messages in thread
From: Schaible, Jorg @ 2002-05-15  4:39 UTC (permalink / raw)
  To: cygwin

Hi Mark,

>The spot where it says:
>  DWORD len = GetShortPathName (filename, NULL, 0);
>  if (len == ERROR_INVALID_PARAMETER)

Ups. 
:)

>By the way I noticed this while I was trying to add a -l 
>option to cygpath
>which is similar to the -s option but it will convert a 
>muddled 8.3 name
>like PROGRA~1 to "Program Files" and I want to know if anyone 
>else might
>have been working on that.

The reason why I just implemented -s (in 1999) was that GetLongPathName is
not available for Win95. If we have to be Win95-compatible still, you will
have to load the function yourself directly form the DLL and use
FindFirstFile (as mensioned in the MSDN docs for *GetShortPathName*) for
every part of the path if the function is not available.

Regards,
Jorg

----

Corinna,

you've seen my own patch for cygpath.cc in cygwin-apps ? Chris already
answered positivly and RH should have the assignment from late 1999 still.
My diff was against the sources from 14.5...

Regards,
Jorg

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2002-05-20 19:42 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-14  8:27 Possible error in cygpath Mark Blackburn
2002-05-14  9:39 ` Corinna Vinschen
2002-05-14 12:53   ` Mark Blackburn
2002-05-14 13:12     ` Mark Blackburn
2002-05-15  5:47     ` Corinna Vinschen
2002-05-15  4:39 Schaible, Jorg
2002-05-15  5:38 ` Corinna Vinschen
2002-05-15 11:10   ` Joerg R. Schaible
2002-05-16 17:12     ` Mark Blackburn
2002-05-17  2:55       ` Corinna Vinschen
2002-05-20 20:42         ` Joerg R. Schaible
2002-05-15 14:21 ` Sam Edge
2002-05-16  7:30   ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).