From: Charles L. Dorian Date: Wed, 9 Dec 2009 19:56:45 +0000 (-0800) Subject: Continuation of issue 221 fix. When 8g or 6g or 5g are called with a X-Git-Tag: weekly.2009-12-09~5 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3ca1b1d27f6bd72dac74ba9e696c002998e54ec5;p=gostls13.git Continuation of issue 221 fix. When 8g or 6g or 5g are called with a UTF-8 string, Yconv() converts it into an octal sequence. If the string converted to more than 30 bytes, the str buffer would overflow. For example, 4 Greek runes became 32 bytes, 3 Hiragana runes became 36 bytes, and 2 Gothic runes became 32 bytes. In 8l, 6l and 5l the function is Sconv(). For some reason, only 5l uses the constant STRINGSZ (defined as 200) for the buffer size. R=rsc https://golang.org/cl/168045 --- diff --git a/src/cmd/5g/list.c b/src/cmd/5g/list.c index d0febaca6d..dfe3bcb79c 100644 --- a/src/cmd/5g/list.c +++ b/src/cmd/5g/list.c @@ -233,7 +233,7 @@ int Yconv(Fmt *fp) { int i, c; - char str[30], *p, *a; + char str[100], *p, *a; a = va_arg(fp->args, char*); p = str; diff --git a/src/cmd/6c/list.c b/src/cmd/6c/list.c index e3a0ea81b4..64afe79fe4 100644 --- a/src/cmd/6c/list.c +++ b/src/cmd/6c/list.c @@ -353,7 +353,7 @@ int Sconv(Fmt *fp) { int i, c; - char str[30], *p, *a; + char str[100], *p, *a; a = va_arg(fp->args, char*); p = str; diff --git a/src/cmd/6g/list.c b/src/cmd/6g/list.c index 41956e63ca..eadd7481bc 100644 --- a/src/cmd/6g/list.c +++ b/src/cmd/6g/list.c @@ -313,7 +313,7 @@ int Yconv(Fmt *fp) { int i, c; - char str[30], *p, *a; + char str[100], *p, *a; a = va_arg(fp->args, char*); p = str; diff --git a/src/cmd/8c/list.c b/src/cmd/8c/list.c index c2ce5b2951..3edaa2e1fb 100644 --- a/src/cmd/8c/list.c +++ b/src/cmd/8c/list.c @@ -274,7 +274,7 @@ int Sconv(Fmt *fp) { int i, c; - char str[30], *p, *a; + char str[100], *p, *a; a = va_arg(fp->args, char*); p = str; diff --git a/src/cmd/8g/list.c b/src/cmd/8g/list.c index f94b9e1766..2a7dc277fd 100644 --- a/src/cmd/8g/list.c +++ b/src/cmd/8g/list.c @@ -256,7 +256,7 @@ int Yconv(Fmt *fp) { int i, c; - char str[30], *p, *a; + char str[100], *p, *a; a = va_arg(fp->args, char*); p = str;