delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/03/14/19:03:15

From: Eric Backus <ericb AT lsid DOT hp DOT com>
Subject: Re: Problem with stat() and long filenames
To: ulrich AT lab1 DOT psy DOT univie DOT ac DOT at
Date: Mon, 14 Mar 94 15:25:27 PST
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Mailer: Elm [revision: 70.85]

> I am using DJGPP 1.11m3 and found the following bug:
> 
>   stat() causes a big crash when called with relative filenames
> longer then (90 - length of <current working directory>), because
> there is a stack buffer p[90] used.
> 
> The buffer p[] should probably changed to:
> 
> 	char *p = (char *) alloca (strlen(path) + MAXPATHLEN);

Gack!  I'm the one who wrote this, and I completely missed this
problem.  The "alloca" solution should work fine, although I tend to
shy away from alloca since it's non-standard.

An alternative solution would be to fix the "_fixpath()" function,
found in libsrc/gen/fixpath.c, to stop after filling up PATH_MAX
characters in the output string.  It should probably then return an
error if the output path got truncated.

I believe PATH_MAX is only 80 (or is it 64) on DOS, so your call to
stat() should in theory fail, although it shouldn't blow up on you
like this.
--
				Eric Backus
				ericb AT lsid DOT hp DOT com
				(206) 335-2495

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019