lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 22 May 2019 09:59:32 +0800
From:   luke <luke.tw@...il.com>
To:     David Laight <David.Laight@...lab.com>
Cc:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "ast@...nel.org" <ast@...nel.org>,
        "daniel@...earbox.net" <daniel@...earbox.net>,
        "kafai@...com" <kafai@...com>,
        "songliubraving@...com" <songliubraving@...com>,
        "yhs@...com" <yhs@...com>
Subject: Re: [PATCH] samples: bpf: fix: change the buffer size for read()

On Tue, May 21, 2019 at 11:05 PM David Laight <David.Laight@...lab.com> wrote:
>
> From: Chang-Hsien Tsai
> > @@ -678,7 +678,7 @@ void read_trace_pipe(void)
> >               static char buf[4096];
> >               ssize_t sz;
> >
> > -             sz = read(trace_fd, buf, sizeof(buf));
> > +             sz = read(trace_fd, buf, sizeof(buf)-1);
> >               if (sz > 0) {
> >                       buf[sz] = 0;
> >                       puts(buf);
>
> Why not change the puts() to fwrite(buf, sz, 1, stdout) ?
> Then you don't need the '\0' terminator.
>
>         David
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
>

Yes.
But, this will be different with the original code.
puts(buf) prints buf and a terminating newline character.

--
Chang-Hsien Tsai

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ