delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/04/29/07:16:02.1

Sender: rich AT phekda DOT freeserve DOT co DOT uk
Message-ID: <3EAE542A.A8D4706@phekda.freeserve.co.uk>
Date: Tue, 29 Apr 2003 11:30:02 +0100
From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586)
X-Accept-Language: de,fr
MIME-Version: 1.0
To: Daniel Borca <dborca AT yahoo DOT com>
CC: djgpp-workers AT delorie DOT com, Charles Sandmann <sandmann AT clio DOT rice DOT edu>
Subject: Re: djgpp: djgpp/src/dxe/dxe3gen.c,dxe3res.c
References: <200304290344 DOT h3T3i6T17655 AT delorie DOT com>
Reply-To: djgpp-workers AT delorie DOT com

Hello.

"cvs-sandmann AT delorie DOT com" wrote:
> 
> Update by cvs id: sandmann
> Update of /cvs/djgpp/djgpp/src/dxe
> 
> Modified Files:
>         dxe3gen.c dxe3res.c
> Log Message:
> Updates from Daniel Borca
> 
[snip]
> ===================================================================
> RCS file: /cvs/djgpp/djgpp/src/dxe/dxe3res.c,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -p -2 -r1.1 -r1.2
> *** djgpp/src/dxe/dxe3res.c     23 Apr 2003 18:53:07 -0000      1.1
> --- djgpp/src/dxe/dxe3res.c     29 Apr 2003 03:44:04 -0000      1.2
[snip]
> *************** static int growtable (symset *s, int adj
> *** 187,190 ****
> --- 187,191 ----
>    if ((s->n+adjust) > s->max) {
>       if ((s->t=(char **)realloc(s->t, (s->max=s->n+adjust+1024)*sizeof(char *))) == NULL) {
> +        errno = ENOMEM;
>          return -1;
>       }

Please don't cast the return value of realloc, malloc, etc.

[snip]
> *************** static char *gettables (const char *file
> *** 287,305 ****
>       char *nextscan;
>       size_t fnl = strlen (filename) + 1;
> !     for (scan = getenv ("LD_LIBRARY_PATH"); scan && *scan; scan = nextscan + strspn (nextscan, "; \t")) {
> !         char *name;
> !         nextscan = strchr (scan, ';');
> !         if (!nextscan) nextscan = strchr (scan, 0);
> !         if (nextscan - scan > FILENAME_MAX - 12)
> !            continue;
> !         memcpy (tempfn, scan, nextscan - scan);
> !         name = tempfn + (nextscan - scan);
> !         if (name [-1] != '/' && name [-1] != '\\')
> !            *name++ = '/';
> !         memcpy (name, filename, fnl);
> !         if (ACCESS(tempfn)) {
> !            filename = tempfn;
> !            goto found;
> !         }
>       }
>       errno = ENOENT;
> --- 288,309 ----
>       char *nextscan;
>       size_t fnl = strlen (filename) + 1;
> !     /* LD_LIBRARY_PATH is scanned only for relative paths */
> !     if ((filename[0] != '/') && (filename[0] != '\\') && (filename[1] != ':')) {
[snip]

Perhaps you need to check that filename[0] is not a nul character here. I
suppose filename must be non-zero in length, since we've already checked that
it can be ACCESS'd. What does ACCESS("") return?

The same comment applies to dlopen.c.

It seems like dxe3res.c and dlopen.c have the same code for looking in
LD_LIBRARY_PATH. Perhaps that should be put in the DXE library code as an
internal function. Then we could avoid some code duplication.

Thanks for the fixes! Bye, Rich =]

-- 
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]

- Raw text -


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