Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1689578

Re: [PATCH] staging: gs_fpgaboot: add buffer overflow checks

From Jacob von Chorus <jacobvonchorus@cwphoto.ca>
Newsgroups linux.kernel
Subject Re: [PATCH] staging: gs_fpgaboot: add buffer overflow checks
Date 2017-07-18 02:30 +0200
Message-ID <u4oyK-3E1-7@gated-at.bofh.it> (permalink)
References <u42eR-6dG-9@gated-at.bofh.it> <u4klr-SQ-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Jul 17, 2017 at 10:53:25PM +0300, Dan Carpenter wrote:
> > +	if (len + 1 > n) {
> 
> It's more idiomatic to say "if (len >= n)".  Plus that's a good habbit

My reasoning behind using "((len + 1) > n)" is that len represents the length of
the string without null-termination. "buf" is required to store a
null-terminator on top of len. Using "len + 1" shows this requirement
more clearly; I will add brackets around "len + 1" for emphasis.

Thanks for the feedback, I will send a v2.

Regards,
Jacob von Chorus

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] staging: gs_fpgaboot: add buffer overflow checks Jacob von Chorus <jacobvonchorus@cwphoto.ca> - 2017-07-17 02:40 +0200
  Re: [PATCH] staging: gs_fpgaboot: add buffer overflow checks Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-07-17 14:30 +0200
  Re: [PATCH] staging: gs_fpgaboot: add buffer overflow checks Dan Carpenter <dan.carpenter@oracle.com> - 2017-07-17 22:00 +0200
    Re: [PATCH] staging: gs_fpgaboot: add buffer overflow checks Jacob von Chorus <jacobvonchorus@cwphoto.ca> - 2017-07-18 02:30 +0200
      Re: [PATCH] staging: gs_fpgaboot: add buffer overflow checks Dan Carpenter <dan.carpenter@oracle.com> - 2017-07-18 10:00 +0200

csiph-web