YMMC yet more malloc checks
Andreas Moroder
claudiamoroder at st-ulrich.suedtirol.net
Wed Aug 8 17:03:09 GMT 2001
It was mistake.
Bye Andreas
-----Ursprüngliche Nachricht-----
Von: "Ryan Waldron" <rew at erebor.com>
An: "Andreas Moroder" <claudiamoroder at st-ulrich.suedtirol.net>
Cc: <samba-technical at lists.samba.org>
Gesendet: Dienstag, 7. August 2001 22:46
Betreff: Re: YMMC yet more malloc checks
> On Tue, 7 Aug 2001, Andreas Moroder wrote:
>
> > in this function even the order is strange, why malloc before the other
> > test.
> > It should be
> >
> > static char *
> > canonicalize (char *path)
> > {
> > char *canonical;
> >
> > if (strlen(path) > PATH_MAX) {
> > fprintf(stderr, "Mount point string too long\n");
> > return NULL;
> > }
> >
> > if (path == NULL)
> > return NULL;
> >
> > canonical= malloc (PATH_MAX + 1);
> > if (canonical==NULL) {
> > fprintf(stderr, "Out of memory\n");
> > return NULL;
> > }
> >
> > if (realpath (path, canonical))
> > return canonical;
> >
> > pstrcpy (canonical, path);
> > return canonical;
> > }
>
> Come to think of it, shouldn't that be:
>
> static char *
> canonicalize (char *path)
> {
> char *canonical;
>
> if (path == NULL)
> return NULL;
>
> if (strlen(path) > PATH_MAX) {
> fprintf(stderr, "Mount point string too long\n");
> return NULL;
> }
>
> ...[etc.]
>
> --
> Ryan Waldron ||| http://www.erebor.com ||| rew at erebor.com
>
> "The web goes ever, ever on, down from the site where it began..."
>
More information about the samba-technical
mailing list