bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] gawk 4.x series mmap attempts to alocates 32GB of memory


From: Aharon Robbins
Subject: Re: [bug-gawk] gawk 4.x series mmap attempts to alocates 32GB of memory and fails when using printf("%c") supplied with large floating point value.
Date: Thu, 10 Jul 2014 15:21:52 -0700
User-agent: Heirloom mailx 12.5 6/20/10

Hello Mr. Fox.

Thank you for reporting a bug.

> Date: Thu, 10 Jul 2014 05:34:41 +0900
> From: green fox <address@hidden>
> To: address@hidden
> Subject: [bug-gawk] gawk 4.x series mmap attempts to alocates 32GB of memory
>  and fails when using printf("%c") supplied with large floating point value.
> Status: R
>
> gawk 4.x series mmap attempts to alocates 32GB of memory and fails
> when using printf("%c") supplied with large floating point value.
>
> Known affected : 4.1.0 - 4.1.60
> Known safe     : 3.1.8
> Arch reproduced: x86_64 , AMD
> Code to reproduce bug:
>   gawk 'BEGIN{printf("%c",sprintf("%c",(0xffffff00+255)));}'|xxd

The patch is below. I will shortly push this into the git repo.

> While sorting out this printf("%c") bug, can we ask for capability to
> write out binary data?
>
> Especially when printf("%c",128) or above, it fails and dumps
> 0xc280, a valid utf-8, but not what was asked.

Please use the -b option to get what you want.

Arnold
-------------------
diff --git a/builtin.c b/builtin.c
index fa03222..7523d6c 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1112,7 +1112,7 @@ out0:
 
                                memset(& state, 0, sizeof(state));
                                count = mbrlen(cp, arg->stlen, & state);
-                               if (count > 0) {
+                               if (count != (size_t) -1 && count != (size_t) 
-2 && count > 0) {
                                        prec = count;
                                        /* may need to increase fw so that 
padding happens, see pr_tail code */
                                        if (fw > 0)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]