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]
Message-ID: <e5a553e3-4138-f8a0-c4d7-ec3d9d46732e@huawei.com>
Date:   Thu, 22 Sep 2022 09:50:54 +0800
From:   wangyufen <wangyufen@...wei.com>
To:     Andrii Nakryiko <andrii.nakryiko@...il.com>
CC:     <andrii@...nel.org>, <ast@...nel.org>, <daniel@...earbox.net>,
        <martin.lau@...ux.dev>, <song@...nel.org>, <yhs@...com>,
        <john.fastabend@...il.com>, <kpsingh@...nel.org>, <sdf@...gle.com>,
        <haoluo@...gle.com>, <jolsa@...nel.org>,
        <paul.walmsley@...ive.com>, <palmer@...belt.com>,
        <aou@...s.berkeley.edu>, <davem@...emloft.net>, <kuba@...nel.org>,
        <hawk@...nel.org>, <nathan@...nel.org>, <ndesaulniers@...gle.com>,
        <trix@...hat.com>, <bpf@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <netdev@...r.kernel.org>,
        <llvm@...ts.linux.dev>
Subject: Re: [bpf-next v3 1/2] libbpf: Add pathname_concat() helper


在 2022/9/22 8:41, Andrii Nakryiko 写道:
> On Sun, Sep 18, 2022 at 7:28 PM Wang Yufen <wangyufen@...wei.com> wrote:
>> Move snprintf and len check to common helper pathname_concat() to make the
>> code simpler.
>>
>> Signed-off-by: Wang Yufen <wangyufen@...wei.com>
>> ---
>>   tools/lib/bpf/libbpf.c | 76 +++++++++++++++++++-------------------------------
>>   1 file changed, 29 insertions(+), 47 deletions(-)
>>
> [...]
>
>> @@ -8009,14 +8012,9 @@ int bpf_object__unpin_maps(struct bpf_object *obj, const char *path)
>>                  char buf[PATH_MAX];
>>
>>                  if (path) {
>> -                       int len;
>> -
>> -                       len = snprintf(buf, PATH_MAX, "%s/%s", path,
>> -                                      bpf_map__name(map));
>> -                       if (len < 0)
>> -                               return libbpf_err(-EINVAL);
>> -                       else if (len >= PATH_MAX)
>> -                               return libbpf_err(-ENAMETOOLONG);
>> +                       err = pathname_concat(path, bpf_map__name(map), buf, PATH_MAX);
>> +                       if (err)
>> +                               return err;
> also keep libbpf_err() as well, it sets errno properly
>
>>                          sanitize_pin_path(buf);
>>                          pin_path = buf;
>>                  } else if (!map->pin_path) {
>> @@ -8034,6 +8032,7 @@ int bpf_object__unpin_maps(struct bpf_object *obj, const char *path)
>>   int bpf_object__pin_programs(struct bpf_object *obj, const char *path)
>>   {
>>          struct bpf_program *prog;
>> +       char buf[PATH_MAX];
>>          int err;
>>
>>          if (!obj)
> [...]


Thanks for your comments, will send v4.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ