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]
Message-ID: <CAHp75Vcpy3+wZ-UuLRMVtvhK8u7X9wAyB8_5t1v8M50NCyTYEA@mail.gmail.com>
Date: Sat, 10 Aug 2024 18:39:20 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Justin Stitt <justinstitt@...gle.com>
Cc: Kees Cook <kees@...nel.org>, Andy Shevchenko <andy@...nel.org>, 
	Andrew Morton <akpm@...ux-foundation.org>, linux-kernel@...r.kernel.org, 
	linux-hardening@...r.kernel.org
Subject: Re: [PATCH] lib/string_helpers: rework overflow-dependent code

On Sat, Aug 10, 2024 at 2:53 AM Justin Stitt <justinstitt@...gle.com> wrote:
> On Fri, Aug 09, 2024 at 02:07:57PM GMT, Andy Shevchenko wrote:
> > On Fri, Aug 9, 2024 at 2:11 AM Kees Cook <kees@...nel.org> wrote:

...

> > Okay, but the patch has an off-by-one error (which has no impact on
> > the behavior as it's close to unrealistic to have the SIZE_MAX array).
> > I prefer that patch can be reconsidered to keep original behaviour,
> > otherwise it might be not so clear why 0 is SIZE_MAX - 1 in _this_
> > case.
>
> Right, it is technically different but still functionally provides the
> "unlimited" behavior.
>
> But, we could  do this too:

>  int string_unescape(char *src, char *dst, size_t size, unsigned int flags)
>  {
>         char *out = dst;
> +       bool unlimited = !size;
>
> -       while (*src && --size) {
> -               if (src[0] == '\\' && src[1] != '\0' && size > 1) {
> +       while (*src && (unlimited || --size)) {
> +               if (src[0] == '\\' && src[1] != '\0' &&
> +                   (unlimited || size > 1)) {
>                         src++;
> -                       size--;
> +                       size -= !unlimited;
>
>                         if (flags & UNESCAPE_SPACE &&
>                                         unescape_space(&src, &out))
>
> Really, I am fine with either.

This one is worse, I think.
Let's take time and not hurry up and think more about better approaches.

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ