From 3ea2f6ca025f6888d3ef2af4fa1e342d84fe1725 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 2 Oct 2007 10:11:56 +0000 Subject: [PATCH] Fixed bug #1646. http error: when trying to callpz2. Pazpar2 crashed due to a memory reference when a connection was NULL for a client. It could become NULL if the client would lose the connection (e.g. timeout). Also added a better diagnostic for the case where multiple record with requests are received by Pazpar2. Bug #1644. --- src/client.c | 8 +++++++- src/http_command.c | 18 +++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/client.c b/src/client.c index 02419ce..4f87d1f 100644 --- a/src/client.c +++ b/src/client.c @@ -1,4 +1,4 @@ -/* $Id: client.c,v 1.25 2007-09-20 09:22:37 adam Exp $ +/* $Id: client.c,v 1.26 2007-10-02 10:11:56 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -239,7 +239,13 @@ int client_show_raw_begin(struct client *cl, int position, size_t sz)) { if (cl->show_raw) + { /* raw show already in progress */ return -1; + } + if (!cl->connection) + { /* the client has no connection */ + return -2; + } cl->show_raw = xmalloc(sizeof(*cl->show_raw)); cl->show_raw->position = position; cl->show_raw->active = 0; diff --git a/src/http_command.c b/src/http_command.c index 052f025..447eb06 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1,4 +1,4 @@ -/* $Id: http_command.c,v 1.62 2007-09-10 16:25:50 adam Exp $ +/* $Id: http_command.c,v 1.63 2007-10-02 10:11:56 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -20,7 +20,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA */ /* - * $Id: http_command.c,v 1.62 2007-09-10 16:25:50 adam Exp $ + * $Id: http_command.c,v 1.63 2007-10-02 10:11:56 adam Exp $ */ #include @@ -568,13 +568,21 @@ static void cmd_record(struct http_channel *c) { http_channel_observer_t obs = http_add_observer(c, r->client, show_raw_reset); - if (client_show_raw_begin(r->client, r->position, syntax, esn, + int ret = + client_show_raw_begin(r->client, r->position, syntax, esn, obs /* data */, show_raw_record_error, - show_raw_record_ok)) + show_raw_record_ok); + if (ret == -1) { http_remove_observer(obs); - error(rs, PAZPAR2_RECORD_FAIL, "invalid parameters"); + error(rs, PAZPAR2_RECORD_FAIL, "show already active"); + return; + } + else if (ret == -2) + { + http_remove_observer(obs); + error(rs, PAZPAR2_NO_SESSION, 0); return; } } -- 1.7.10.4