Re: [PATCH] src: Fix another build warning / error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 12, 2018 at 08:31:49PM +0200, Pablo Neira Ayuso wrote:
> On Tue, Jun 12, 2018 at 01:25:35PM +1000, Duncan Roe wrote:
> > gcc 8.1 warns when it can detect that a strncpy may result in a string with no
> > null terminator. It also warns when it can similarly detect that an snprintf may
> > discard characters, unless the return value from that snprintf is tested.
> > gcc 8.1.0 (latest release) does not complain about the patched line, but the
> > gcc 8.1.1 snapshot that comes with FC28 does.
>
> Thanks Duncan!
>
> But it seems this patch doesn't apply cleanly to ebtables.git?
>
> $ patch -p1 < /tmp/src-Fix-another-build-warning-error.patch
> patching file extensions/ebt_string.c
> Hunk #1 FAILED at 168.
> 1 out of 1 hunk FAILED -- saving rejects to file
> extensions/ebt_string.c.rej
>
> Let me know!

Hi Pablo,

I hadn't pulled fw's commit 56993546c80576986930f9bae7ae4ba744b1e508 which
addresses the same problem:
  sufficiently new gcc correctly flags a warning that strncpy could make a
  string w/out a NUL terminator.
  snprintf guarantees NUL-termination (so fixes that possibility).
  But, snprintf may discard data to make room for the NUL. Recent gcc flags a
  warning when it can detect that may happen (it can't here).
  When gcc does warn about an sprintf call, the warning goes away when you
  test the return value, which tells you whether data was discarded.
  The patch I'll sent in does this check anyway. I can send a v2 to reinstate
  the check (later, have to dash off now).
>
> P.S: BTW, I would suggest a patch subject like: "extensions:
> ebt_string: fix compilation warning related to strncpy" or similar

Thanks for that - will be more careful in future.

Cheers ... Duncan.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux