Bounds check terms based in ICU norm
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 21 May 2012 14:21:01 +0000 (16:21 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 21 May 2012 14:21:01 +0000 (16:21 +0200)
index/extract.c
index/kinput.c

index 6f4a812..a93373c 100644 (file)
@@ -1798,6 +1798,11 @@ static void extract_add_icu(RecWord *p, zebra_map_t zm)
     zebra_map_tokenize_start(zm, p->term_buf, p->term_len);
     while (zebra_map_tokenize_next(zm, &res_buf, &res_len, 0, 0))
     {
+        if (res_len > IT_MAX_WORD)
+        {
+            yaz_log(YLOG_LOG, "Truncating long term %ld", (long) res_len);
+            res_len = IT_MAX_WORD;
+        }
         extract_add_string(p, zm, res_buf, res_len);
         p->seqno++;
     }
index ddc58ae..851c13e 100644 (file)
@@ -328,6 +328,8 @@ static void key_heap_insert(struct heap_info *hi, const char *buf, int nbytes,
 {
     int cur, parent;
 
+    assert(nbytes < INP_NAME_MAX);
+
     cur = ++(hi->heapnum);
     memcpy(hi->info.buf[hi->ptr[cur]], buf, nbytes);
     hi->info.file[hi->ptr[cur]] = kf;