From 0f2cb94ed7cb9bb25b8f7825cb66d071db65dd1f Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 28 May 2026 10:04:13 +0200 Subject: [PATCH 1/8] marc read line: fix const assign warning More focused removal of blank between subfield and data --- src/marc_read_line.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/marc_read_line.c b/src/marc_read_line.c index 7bfa19832..f69308f3e 100644 --- a/src/marc_read_line.c +++ b/src/marc_read_line.c @@ -216,20 +216,14 @@ int yaz_marc_read_line(yaz_marc_t mt, if (next) len = next - cp - marker_skip; - if (marker_skip) + if (marker_skip && len > 2 && cp[2] == ' ') { /* remove ' ' after subfield marker */ - char *cp_blank = strchr(cp, ' '); - if (cp_blank) - { - len--; - while (cp_blank != cp) - { - cp_blank[0] = cp_blank[-1]; - cp_blank--; - } - cp++; - } + char *cp_mod = (char *) cp; /* line is allocated locally, so we can modify it */ + cp_mod[2] = cp_mod[1]; + cp_mod[1] = cp_mod[0]; + len--; + cp++; } yaz_marc_add_subfield(mt, cp, len); if (!next) From d3b6483bed507cd854ca9fa03099d619ec91be84 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 28 May 2026 10:11:09 +0200 Subject: [PATCH 2/8] Avoid removing const buffer --- src/zoom-record-cache.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/zoom-record-cache.c b/src/zoom-record-cache.c index 957e8f911..f13fc21bc 100644 --- a/src/zoom-record-cache.c +++ b/src/zoom-record-cache.c @@ -109,11 +109,11 @@ static ZOOM_record record_cache_add(ZOOM_resultset r, { if (diag->uri) { - char *cp; - rc->rec.diag_set = odr_strdup(r->odr, diag->uri); - if ((cp = strrchr(rc->rec.diag_set, '/'))) - *cp = '\0'; - rc->rec.diag_uri = odr_strdup(r->odr, diag->uri); + const char *cp = strrchr(rc->rec.diag_set, '/'); + if (cp) + rc->rec.diag_set = odr_strdupn(r->odr, diag->uri, cp - diag->uri); + else + rc->rec.diag_uri = odr_strdup(r->odr, diag->uri); } rc->rec.diag_message = odr_strdup_null(r->odr, diag->message); rc->rec.diag_details = odr_strdup_null(r->odr, diag->details); From 8095bbef7356744792427f0497d69ee7b5f77a46 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 28 May 2026 10:14:26 +0200 Subject: [PATCH 3/8] Avoid removing const buffer --- src/solr.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/solr.c b/src/solr.c index 93f005878..1e5614f1c 100644 --- a/src/solr.c +++ b/src/solr.c @@ -261,7 +261,7 @@ static int yaz_solr_decode_scan_result(ODR o, xmlNodePtr ptr, Z_SRW_scanResponse *scr) { xmlNodePtr node; - char *pos; + const char *pos; int i = 0; /* find the actual list */ @@ -297,19 +297,17 @@ static int yaz_solr_decode_scan_result(ODR o, xmlNodePtr ptr, * This is due to SOLR not being able to encode them into 2 separate attributes. */ pos = strchr(val, '^'); - if (pos != NULL) + if (pos) { term->displayTerm = odr_strdup(o, pos + 1); - *pos = '\0'; - term->value = odr_strdup(o, val); - *pos = '^'; + term->value = odr_strdupn(o, val, pos - val); } else { term->value = odr_strdup(o, val); - term->displayTerm = NULL; + term->displayTerm = 0; } - term->whereInList = NULL; + term->whereInList = 0; i++; } } From 44bc76d49be03fb2962894fe103cab26c738ec78 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 28 May 2026 10:15:42 +0200 Subject: [PATCH 4/8] add const --- src/retrieval.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/retrieval.c b/src/retrieval.c index 793580053..abecbe542 100644 --- a/src/retrieval.c +++ b/src/retrieval.c @@ -318,7 +318,7 @@ int yaz_retrieval_request(yaz_retrieval_t p, schema_ok = 1; else { - char *cp = 0; + const char *cp = 0; wrbuf_rewind(w); if (el->split && *el->split && (cp = strchr(schema, *el->split))) wrbuf_write(w, schema, cp - schema); @@ -361,7 +361,7 @@ int yaz_retrieval_request(yaz_retrieval_t p, { if (*el->backend_name) { - char *cp; + const char *cp; wrbuf_rewind(w); wrbuf_puts(w, el->backend_name); if (el->split && *el->split && schema From 5b29c2950a8dc11637ae885dff38e305fda676f4 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 28 May 2026 10:34:25 +0200 Subject: [PATCH 5/8] Avoid deprecated xmlSAXUserParseMemory --- test/test_marc_read_sax.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/test_marc_read_sax.c b/test/test_marc_read_sax.c index 7f335ce89..90029a6fe 100644 --- a/test/test_marc_read_sax.c +++ b/test/test_marc_read_sax.c @@ -41,8 +41,16 @@ static void tst1(void) yaz_marc_t mt = yaz_marc_create(); yaz_marc_sax_t yt = yaz_marc_sax_new(mt, handler, &user_data); xmlSAXHandlerPtr sax_ptr = yaz_marc_sax_get_handler(yt); + xmlParserCtxtPtr parser_ctxt = xmlCreatePushParserCtxt(sax_ptr, yt, + marcxml, + strlen(marcxml), 0); - xmlSAXUserParseMemory(sax_ptr, yt, marcxml, strlen(marcxml)); + YAZ_CHECK(parser_ctxt); + if (parser_ctxt) + { + YAZ_CHECK_EQ(xmlParseChunk(parser_ctxt, 0, 0, 1), 0); + xmlFreeParserCtxt(parser_ctxt); + } const char *expect = "\n" " 00062cgm a2200037Ia 4500\n" From 95b0b9dd1e9579db011e0bbdf05017ae355c7070 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 28 May 2026 10:34:32 +0200 Subject: [PATCH 6/8] Include config.h first --- test/test_tpath.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/test_tpath.c b/test/test_tpath.c index d199aadb6..265df9786 100644 --- a/test/test_tpath.c +++ b/test/test_tpath.c @@ -2,15 +2,14 @@ * Copyright (C) Index Data * See the file LICENSE for details. */ -#include -#include -#include -#include - #if HAVE_CONFIG_H #include #endif +#include +#include +#include +#include static void tst_tpath(void) { From 028692bbe75f474aa51ac58939a5ee14f27f099c Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 28 May 2026 10:51:57 +0200 Subject: [PATCH 7/8] Fix --- src/zoom-record-cache.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/zoom-record-cache.c b/src/zoom-record-cache.c index f13fc21bc..d83006f18 100644 --- a/src/zoom-record-cache.c +++ b/src/zoom-record-cache.c @@ -109,11 +109,12 @@ static ZOOM_record record_cache_add(ZOOM_resultset r, { if (diag->uri) { - const char *cp = strrchr(rc->rec.diag_set, '/'); + const char *cp = strrchr(diag->uri, '/'); if (cp) rc->rec.diag_set = odr_strdupn(r->odr, diag->uri, cp - diag->uri); else - rc->rec.diag_uri = odr_strdup(r->odr, diag->uri); + rc->rec.diag_set = odr_strdup(r->odr, diag->uri); + rc->rec.diag_uri = odr_strdup(r->odr, diag->uri); } rc->rec.diag_message = odr_strdup_null(r->odr, diag->message); rc->rec.diag_details = odr_strdup_null(r->odr, diag->details); From 375047c56a7278dbdca4e6c0e563747369bfb905 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 28 May 2026 12:09:36 +0200 Subject: [PATCH 8/8] Fix --- src/marc_read_line.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/marc_read_line.c b/src/marc_read_line.c index f69308f3e..000e81863 100644 --- a/src/marc_read_line.c +++ b/src/marc_read_line.c @@ -201,13 +201,14 @@ int yaz_marc_read_line(yaz_marc_t mt, next = cp; while ((next = strchr(next, marker_ch))) { + /* allow only alphanumeric characters */ if ((next[1] >= 'A' && next[1] <= 'Z') ||(next[1] >= 'a' && next[1] <= 'z') ||(next[1] >= '0' && next[1] <= '9')) { if (!marker_skip) break; - else if (next[2] == ' ') + else if (next[-1] == ' ') break; } next++; @@ -216,12 +217,11 @@ int yaz_marc_read_line(yaz_marc_t mt, if (next) len = next - cp - marker_skip; - if (marker_skip && len > 2 && cp[2] == ' ') + if (marker_skip && len > 1 && cp[1] == ' ') { /* remove ' ' after subfield marker */ char *cp_mod = (char *) cp; /* line is allocated locally, so we can modify it */ - cp_mod[2] = cp_mod[1]; - cp_mod[1] = cp_mod[0]; + cp_mod[1] = cp_mod[0]; /* does not deal with multi-byte subfields */ len--; cp++; }