avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcrea...@apache.org
Subject svn commit: r1384543 - in /avro/trunk: CHANGES.txt lang/c/src/value-read.c
Date Thu, 13 Sep 2012 21:24:26 GMT
Author: dcreager
Date: Thu Sep 13 21:24:25 2012
New Revision: 1384543

URL: http://svn.apache.org/viewvc?rev=1384543&view=rev
Log:
AVRO-1159. C: Check union discriminant in avro_value_read.

Contributed by Lucas Martin-King.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/c/src/value-read.c

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1384543&r1=1384542&r2=1384543&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Thu Sep 13 21:24:25 2012
@@ -64,6 +64,9 @@ Avro 1.7.2 (unreleased)
     AVRO-1158. C: Fixed infinite loop in deflate decompression codec.
     (Lucas Martin-King via dcreager)
 
+    AVRO-1159. C: Check union discriminants in avro_value_read.
+    (Lucas Martin-King via dcreager)
+
 Avro 1.7.1 (16 July 2012)
 
   NEW FEATURES

Modified: avro/trunk/lang/c/src/value-read.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/value-read.c?rev=1384543&r1=1384542&r2=1384543&view=diff
==============================================================================
--- avro/trunk/lang/c/src/value-read.c (original)
+++ avro/trunk/lang/c/src/value-read.c Thu Sep 13 21:24:25 2012
@@ -165,6 +165,13 @@ read_union_value(avro_reader_t reader, a
 	check_prefix(rval, avro_binary_encoding.
 		     read_long(reader, &discriminant),
 		     "Cannot read union discriminant: ");
+
+	if (discriminant < 0) {
+		avro_set_error("Invalid union discriminant value: (%d)",
+			       discriminant);
+		return 1;
+	}
+
 	check(rval, avro_value_set_branch(dest, discriminant, &branch));
 	check(rval, read_value(reader, &branch));
 	return 0;



Mime
View raw message