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] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 27 May 2019 22:19:04 -0700
From:   Y Song <ys114321@...il.com>
To:     Chang-Hsien Tsai <luke.tw@...il.com>
Cc:     netdev <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>
Subject: Re: [PATCH] [PATCH bpf] style fix in while(!feof()) loop

On Sun, May 26, 2019 at 3:35 AM Chang-Hsien Tsai <luke.tw@...il.com> wrote:
>
> use fgets() as the while loop condition.
>
> Signed-off-by: Chang-Hsien Tsai <luke.tw@...il.com>
Looks like right now we did not really differentiate error in fgets from EOF,
so the change is in this patch is equivalent to its previous behavior.

Acked-by: Yonghong Song <yhs@...com>

> ---
>  tools/bpf/bpftool/xlated_dumper.c           | 4 +---
>  tools/testing/selftests/bpf/trace_helpers.c | 4 +---
>  2 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/tools/bpf/bpftool/xlated_dumper.c b/tools/bpf/bpftool/xlated_dumper.c
> index 0bb17bf88b18..494d7ae3614d 100644
> --- a/tools/bpf/bpftool/xlated_dumper.c
> +++ b/tools/bpf/bpftool/xlated_dumper.c
> @@ -31,9 +31,7 @@ void kernel_syms_load(struct dump_data *dd)
>         if (!fp)
>                 return;
>
> -       while (!feof(fp)) {
> -               if (!fgets(buff, sizeof(buff), fp))
> -                       break;
> +       while (fgets(buff, sizeof(buff), fp)) {
>                 tmp = reallocarray(dd->sym_mapping, dd->sym_count + 1,
>                                    sizeof(*dd->sym_mapping));
>                 if (!tmp) {
> diff --git a/tools/testing/selftests/bpf/trace_helpers.c b/tools/testing/selftests/bpf/trace_helpers.c
> index 9a9fc6c9b70b..b47f205f0310 100644
> --- a/tools/testing/selftests/bpf/trace_helpers.c
> +++ b/tools/testing/selftests/bpf/trace_helpers.c
> @@ -30,9 +30,7 @@ int load_kallsyms(void)
>         if (!f)
>                 return -ENOENT;
>
> -       while (!feof(f)) {
> -               if (!fgets(buf, sizeof(buf), f))
> -                       break;
> +       while (fgets(buf, sizeof(buf), f)) {
>                 if (sscanf(buf, "%p %c %s", &addr, &symbol, func) != 3)
>                         break;
>                 if (!addr)
> --
> 2.17.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ