From b81eb4e30e5febe06da7118cd9a84a63604cb1e0 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 10 Sep 2008 14:50:00 +0200 Subject: [PATCH] Proper sort entry copying --- index/zsets.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/index/zsets.c b/index/zsets.c index 5187cf4..225876c 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -581,18 +581,31 @@ void resultSetInsertSort(ZebraHandle zh, ZebraSet sset, int off = 0; while (off != wrbuf_len(w)) { + size_t l = strlen(wrbuf_buf(w)+off); assert(off < wrbuf_len(w)); + + if (l >= SORT_IDX_ENTRYSIZE) + l = SORT_IDX_ENTRYSIZE-1; if (off == 0) - strcpy(this_entry_buf, wrbuf_buf(w)); + { + memcpy(this_entry_buf, wrbuf_buf(w)+off, l); + this_entry_buf[l] = '\0'; + } else if (criteria[i].relation == 'A') { if (strcmp(wrbuf_buf(w)+off, this_entry_buf) < 0) - strcpy(this_entry_buf, wrbuf_buf(w)+off); + { + memcpy(this_entry_buf, wrbuf_buf(w)+off, l); + this_entry_buf[l] = '\0'; + } } else if (criteria[i].relation == 'D') { if (strcmp(wrbuf_buf(w)+off, this_entry_buf) > 0) - strcpy(this_entry_buf, wrbuf_buf(w)+off); + { + memcpy(this_entry_buf, wrbuf_buf(w)+off, l); + this_entry_buf[l] = '\0'; + } } off += 1 + strlen(wrbuf_buf(w)+off); } -- 1.7.10.4