FAQ
Reviewers: golang-dev1,

Message:
Hello golang-dev@googlegroups.com,

I'd like you to review this change to
https://code.google.com/p/go/


Description:
cmd/gc: fix overflow in array bounds calculation.

Fixes issue 5609.

Please review this at https://codereview.appspot.com/9757045/

Affected files:
    M src/cmd/gc/typecheck.c
    A test/fixedbugs/issue5609.go


Index: src/cmd/gc/typecheck.c
===================================================================
--- a/src/cmd/gc/typecheck.c
+++ b/src/cmd/gc/typecheck.c
@@ -420,12 +420,12 @@
       goto error;
      }
      t->bound = mpgetfix(v.u.xval);
- if(t->bound < 0) {
+ if(doesoverflow(v, types[TINT])) {
+ yyerror("array bound is too large");
+ goto error;
+ } else if(t->bound < 0) {
       yyerror("array bound must be non-negative");
       goto error;
- } else if(doesoverflow(v, types[TINT])) {
- yyerror("array bound is too large");
- goto error;
      }
     }
     typecheck(&r, Etype);
Index: test/fixedbugs/issue5609.go
===================================================================
new file mode 100644
--- /dev/null
+++ b/test/fixedbugs/issue5609.go
@@ -0,0 +1,13 @@
+// errorcheck
+
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// issue 5609: overflow when calculating array size
+
+package pkg
+
+const Large uint64 = 18446744073709551615
+
+var foo [Large]uint64 // ERROR "array bound is too large"


--

---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Remyoudompheng at Jun 1, 2013 at 11:36 am
    LGTM

    https://codereview.appspot.com/9757045/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • R at Jun 1, 2013 at 1:40 pm
    LGTM

    https://codereview.appspot.com/9757045/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Daniel Morsing at Jun 1, 2013 at 2:34 pm
    *** Submitted as
    https://code.google.com/p/go/source/detail?r=aad6852cbd65 ***

    cmd/gc: fix overflow in array bounds calculation.

    Fixes issue 5609.

    R=golang-dev, remyoudompheng, r
    CC=golang-dev
    https://codereview.appspot.com/9757045


    https://codereview.appspot.com/9757045/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedJun 1, '13 at 11:33a
activeJun 1, '13 at 2:34p
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase