Fixed bug #643: Bad sequence for MARC conversions from UTF-8 to MARC-8.
[yaz-moved-to-github.git] / src / seshigh.c
index 261b617..2a3fc2f 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: seshigh.c,v 1.95 2006-07-31 12:15:02 adam Exp $
+ * $Id: seshigh.c,v 1.96 2006-08-24 13:25:45 adam Exp $
  */
 /**
  * \file seshigh.c
@@ -340,7 +340,7 @@ void ir_session(IOCHAN h, int event)
             }
             assoc->cs_get_mask = EVENT_INPUT;
             if ((res = cs_get(conn, &assoc->input_buffer,
-                &assoc->input_buffer_len)) <= 0)
+                &assoc->input_buffer_len)) == 0)
             {
                 yaz_log(log_sessiondetail, "Connection closed by client");
                 cs_close(conn);
@@ -348,6 +348,15 @@ void ir_session(IOCHAN h, int event)
                 iochan_destroy(h);
                 return;
             }
+            else if (res < 0)
+            {
+                yaz_log(log_session, "Connection error: %s",
+                        cs_errmsg(cs_errno(conn)));
+                req = request_get(&assoc->incoming); /* get a new request */
+                do_close_req(assoc, Z_Close_protocolError, 
+                             "Incoming package too large", req);
+                return;
+            }
             else if (res == 1) /* incomplete read - wait for more  */
             {
                 if (conn->io_pending & CS_WANT_WRITE)
@@ -378,7 +387,7 @@ void ir_session(IOCHAN h, int event)
                     yaz_log(YLOG_WARN, "PDU dump:");
                     odr_dumpBER(yaz_log_file(), assoc->input_buffer, res);
                     request_release(req);
-                    do_close(assoc, Z_Close_protocolError,"Malformed package");
+                    do_close(assoc, Z_Close_protocolError, "Malformed package");
                 }
                 else
                 {
@@ -2317,7 +2326,7 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
                 assoc->init->implementation_name,
                 odr_prepend(assoc->encode, "GFS", resp->implementationName));
 
-    version = odr_strdup(assoc->encode, "$Revision: 1.95 $");
+    version = odr_strdup(assoc->encode, "$Revision: 1.96 $");
     if (strlen(version) > 10)   /* check for unexpanded CVS strings */
         version[strlen(version)-2] = '\0';
     resp->implementationVersion = odr_prepend(assoc->encode,