[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] ftpfs: fix host lookup error handling
From: |
Krzysztof Piecuch |
Subject: |
Re: [PATCH] ftpfs: fix host lookup error handling |
Date: |
Wed, 28 Aug 2019 19:10:25 +0000 |
Hello,
thanks for the code review. I'll submit fixes in a while.
Kind regards,
Krzysztof Piecuch
Sent with ProtonMail Secure Email.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Monday, August 26, 2019 7:36 PM, Samuel Thibault <samuel.thibault@gnu.org>
wrote:
> Hello,
>
> Krzysztof Piecuch, le lun. 26 août 2019 17:54:55 +0000, a ecrit:
>
> > - if (gethostbyname_r (host, &_he, hostent_data, sizeof hostent_data,
> > - &he, h_err) == 0)
> >
> >
> >
> > - do {
> > - bufsize *= 2;
> > - hostent_data = realloc(hostent_data, bufsize);
> > - if (!hostent_data)
> > - err = ENOMEM;
> >
> >
>
> When realloc fails, the previous buffer is not released, so you mustn't
> immediately overwrite hostent_data with the new pointer, but use an
> intermediate temporary variable.
>
> > - retval = gethostbyname_r (host, &_he, hostent_data, bufsize,
> > - &he, h_err);
> >
> >
> > - } while (!err && retval == ERANGE && bufsize < bufsizemax);
>
> The GNU Coding Style prefers to use err == 0. Also replace the two
> spaces with just one space.
>
> > else
> > err = EINVAL;
>
> This will overwrite the ENOMEM mentioned above.
>
> In the commit log, please not only mention why the commit, but also what
> it contains, see previous log entries for instance. Here you could have
>
> - ftpfs/host.c (lookup_server): Fix coding style. On ENOMEM of realloc,
> return ENOMEM instead of overwriting it with EINVAL.
>
> Samuel
>