Repository: lucy
Updated Branches:
  refs/heads/master 4370756cc -> 8b4ad2105


Forbid fields above 2 GB.

Check for fields above 2 GB before the document enters the any writer
subcomponents below SegWriter.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/451c469c
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/451c469c
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/451c469c

Branch: refs/heads/master
Commit: 451c469cfdea48be9ea6f21bb7437b26f98f2b9b
Parents: 4370756
Author: Marvin Humphrey <mar...@rectangular.com>
Authored: Wed Apr 20 16:46:42 2016 -0700
Committer: Marvin Humphrey <mar...@rectangular.com>
Committed: Wed Apr 20 19:25:02 2016 -0700

----------------------------------------------------------------------
 core/Lucy/Index/Inverter.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/451c469c/core/Lucy/Index/Inverter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Inverter.c b/core/Lucy/Index/Inverter.c
index 1cdf606..d5a684a 100644
--- a/core/Lucy/Index/Inverter.c
+++ b/core/Lucy/Index/Inverter.c
@@ -17,6 +17,7 @@
 #define C_LUCY_INVERTER
 #define C_LUCY_INVERTERENTRY
 #include "Lucy/Util/ToolSet.h"
+#include "Clownfish/Blob.h"
 
 #include "Lucy/Index/Inverter.h"
 #include "Lucy/Analysis/Analyzer.h"
@@ -155,6 +156,23 @@ Inverter_Add_Field_IMP(Inverter *self, InverterEntry 
*entry) {
     InverterIVARS *const ivars = Inverter_IVARS(self);
     InverterEntryIVARS *const entry_ivars = InvEntry_IVARS(entry);
 
+    if (entry_ivars->type) {
+        if (Obj_is_a((Obj*)entry_ivars->type, TEXTTYPE)) {
+            String *value = (String*)entry_ivars->value;
+            if (value != NULL && Str_Get_Size(value) > INT32_MAX) {
+                THROW(ERR, "Can't index strings over 2GB: %u64",
+                      (uint64_t)Str_Get_Size(value));
+            }
+        }
+        else if (Obj_is_a((Obj*)entry_ivars->type, BLOBTYPE)) {
+            Blob *value = (Blob*)entry_ivars->value;
+            if (value != NULL && Blob_Get_Size(value) > INT32_MAX) {
+                THROW(ERR, "Can't index strings over 2GB: %u64",
+                      (uint64_t)Blob_Get_Size(value));
+            }
+        }
+    }
+
     // Get an Inversion, going through analyzer if appropriate.
     if (entry_ivars->analyzer) {
         DECREF(entry_ivars->inversion);

Reply via email to