all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: master b5f17fe07c6: * admin/unidata/emoji-zwj.awk: Avoid sprint buffer overflow
       [not found] ` <20230603105824.B5ECBC21A9D@vcs2.savannah.gnu.org>
@ 2023-06-03 11:18   ` Robert Pluim
  2023-06-03 12:18     ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Robert Pluim @ 2023-06-03 11:18 UTC (permalink / raw)
  To: emacs-devel; +Cc: Mattias Engdegård

>>>>> On Sat,  3 Jun 2023 06:58:23 -0400 (EDT), Mattias Engdegård <mattiase@acm.org> said:

    Mattias> branch: master
    Mattias> commit b5f17fe07c6624380ba8d0c7a400a6b89f225209
    Mattias> Author: Mattias Engdegård <mattiase@acm.org>
    Mattias> Commit: Mattias Engdegård <mattiase@acm.org>

    Mattias>     * admin/unidata/emoji-zwj.awk: Avoid sprint buffer overflow
    
    Mattias>     Some AWK implementations have a fixed buffer for sprintf; for mawk the
    Mattias>     default size is 8192 bytes.  Hoist a string concatenation from
    Mattias>     a sprintf call to avoid running into that limit.  See discussion at
    Mattias>     https://lists.gnu.org/archive/html/emacs-devel/2023-06/msg00090.html .
    Mattias> ---
    Mattias>  admin/unidata/emoji-zwj.awk | 2 +-
    Mattias>  1 file changed, 1 insertion(+), 1 deletion(-)

    Mattias> diff --git a/admin/unidata/emoji-zwj.awk b/admin/unidata/emoji-zwj.awk
    Mattias> index f13f796bcac..4b648aa675e 100644
    Mattias> --- a/admin/unidata/emoji-zwj.awk
    Mattias> +++ b/admin/unidata/emoji-zwj.awk
    Mattias> @@ -106,7 +106,7 @@ END {
 
    Mattias>       for (elt in ch)
    Mattias>      {
    Mattias> -        entries = sprintf("%s\n\"\\N{U+%s}\\N{U+FE0E}\"\n\"\\N{U+%s}\\N{U+FE0F}\"", vec[elt], elt, elt)
    Mattias> +        entries = vec[elt] sprintf("\n\"\\N{U+%s}\\N{U+FE0E}\"\n\"\\N{U+%s}\\N{U+FE0F}\"", elt, elt)
    Mattias>          printf("(#x%s .\n,(eval-when-compile (regexp-opt\n'(\n%s\n))))\n", elt, entries)
    Mattias>      }
    Mattias>       print "))"

Fair enough. I always forget that awk can do string concatenation (and
this should go to emacs-29 as well).

Robert
-- 



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: master b5f17fe07c6: * admin/unidata/emoji-zwj.awk: Avoid sprint buffer overflow
  2023-06-03 11:18   ` master b5f17fe07c6: * admin/unidata/emoji-zwj.awk: Avoid sprint buffer overflow Robert Pluim
@ 2023-06-03 12:18     ` Andreas Schwab
  2023-06-03 14:41       ` Mattias Engdegård
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2023-06-03 12:18 UTC (permalink / raw)
  To: Robert Pluim; +Cc: emacs-devel, Mattias Engdegård

On Jun 03 2023, Robert Pluim wrote:

>>>>>> On Sat,  3 Jun 2023 06:58:23 -0400 (EDT), Mattias Engdegård <mattiase@acm.org> said:
>
>     Mattias> branch: master
>     Mattias> commit b5f17fe07c6624380ba8d0c7a400a6b89f225209
>     Mattias> Author: Mattias Engdegård <mattiase@acm.org>
>     Mattias> Commit: Mattias Engdegård <mattiase@acm.org>
>
>     Mattias>     * admin/unidata/emoji-zwj.awk: Avoid sprint buffer overflow
>     
>     Mattias>     Some AWK implementations have a fixed buffer for sprintf; for mawk the
>     Mattias>     default size is 8192 bytes.  Hoist a string concatenation from
>     Mattias>     a sprintf call to avoid running into that limit.  See discussion at
>     Mattias>     https://lists.gnu.org/archive/html/emacs-devel/2023-06/msg00090.html .
>     Mattias> ---
>     Mattias>  admin/unidata/emoji-zwj.awk | 2 +-
>     Mattias>  1 file changed, 1 insertion(+), 1 deletion(-)
>
>     Mattias> diff --git a/admin/unidata/emoji-zwj.awk b/admin/unidata/emoji-zwj.awk
>     Mattias> index f13f796bcac..4b648aa675e 100644
>     Mattias> --- a/admin/unidata/emoji-zwj.awk
>     Mattias> +++ b/admin/unidata/emoji-zwj.awk
>     Mattias> @@ -106,7 +106,7 @@ END {
>  
>     Mattias>       for (elt in ch)
>     Mattias>      {
>     Mattias> -        entries = sprintf("%s\n\"\\N{U+%s}\\N{U+FE0E}\"\n\"\\N{U+%s}\\N{U+FE0F}\"", vec[elt], elt, elt)
>     Mattias> +        entries = vec[elt] sprintf("\n\"\\N{U+%s}\\N{U+FE0E}\"\n\"\\N{U+%s}\\N{U+FE0F}\"", elt, elt)
>     Mattias>          printf("(#x%s .\n,(eval-when-compile (regexp-opt\n'(\n%s\n))))\n", elt, entries)
>     Mattias>      }
>     Mattias>       print "))"
>
> Fair enough. I always forget that awk can do string concatenation (and
> this should go to emacs-29 as well).

In fact, there is no need for sprintf in the first place.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: master b5f17fe07c6: * admin/unidata/emoji-zwj.awk: Avoid sprint buffer overflow
  2023-06-03 12:18     ` Andreas Schwab
@ 2023-06-03 14:41       ` Mattias Engdegård
  0 siblings, 0 replies; 3+ messages in thread
From: Mattias Engdegård @ 2023-06-03 14:41 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Robert Pluim, emacs-devel

3 juni 2023 kl. 14.18 skrev Andreas Schwab <schwab@linux-m68k.org>:

> In fact, there is no need for sprintf in the first place.

That's right, but I didn't want to change more than necessary, to reduce the risk. Awk isn't directly known for its strong static checking.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-03 14:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <168578990322.1417.10991974872591826827@vcs2.savannah.gnu.org>
     [not found] ` <20230603105824.B5ECBC21A9D@vcs2.savannah.gnu.org>
2023-06-03 11:18   ` master b5f17fe07c6: * admin/unidata/emoji-zwj.awk: Avoid sprint buffer overflow Robert Pluim
2023-06-03 12:18     ` Andreas Schwab
2023-06-03 14:41       ` Mattias Engdegård

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.