Fix SEGV for quit command in cmdfile
[yaz-moved-to-github.git] / client / client.c
index 0cf0cad..2692a9c 100644 (file)
@@ -435,8 +435,8 @@ static int process_initResponse(Z_InitResponse *res)
                 else
                 {
                     /* Peek at any private Init-diagnostic APDUs */
-                    printf("### NAUGHTY: External is '%.*s'\n",
-                           sat->len, sat->buf);
+                    printf("yaz-client ignoring unrecognised userInformationField: %d-octet External '%.*s'\n",
+                           (int) sat->len, sat->len, sat->buf);
                 }
             }
             odr_reset(print);
@@ -760,7 +760,7 @@ int cmd_authentication(const char *arg)
     }
     else if (r == 1)
     {
-        auth = nmem_malloc(nmem_auth, sizeof(*auth));
+        auth = (Z_IdAuthentication *) nmem_malloc(nmem_auth, sizeof(*auth));
         if (!strcmp(args[0], "-"))
         {
             auth->which = Z_IdAuthentication_anonymous;
@@ -776,9 +776,10 @@ int cmd_authentication(const char *arg)
     }
     else if (r == 2)
     {
-        auth = nmem_malloc(nmem_auth, sizeof(*auth));
+        auth = (Z_IdAuthentication *) nmem_malloc(nmem_auth, sizeof(*auth));
         auth->which = Z_IdAuthentication_idPass;
-        auth->u.idPass = nmem_malloc(nmem_auth, sizeof(*auth->u.idPass));
+        auth->u.idPass = (Z_IdPass *)
+            nmem_malloc(nmem_auth, sizeof(*auth->u.idPass));
         auth->u.idPass->groupId = NULL;
         auth->u.idPass->userId = !strcmp(args[0], "-") ? 0 : args[0];
         auth->u.idPass->password = !strcmp(args[1], "-") ? 0 : args[1];
@@ -787,9 +788,10 @@ int cmd_authentication(const char *arg)
     }
     else if (r == 3)
     {
-        auth = nmem_malloc(nmem_auth, sizeof(*auth));
+        auth = (Z_IdAuthentication*) nmem_malloc(nmem_auth, sizeof(*auth));
         auth->which = Z_IdAuthentication_idPass;
-        auth->u.idPass = nmem_malloc(nmem_auth, sizeof(*auth->u.idPass));
+        auth->u.idPass = (Z_IdPass *)
+            nmem_malloc(nmem_auth, sizeof(*auth->u.idPass));
         auth->u.idPass->groupId = args[1];
         auth->u.idPass->userId = args[0];
         auth->u.idPass->password = args[2];
@@ -3897,9 +3899,10 @@ static void initialize(const char *rc_file)
 
     cmd_format("usmarc");
 
+    file_history = file_history_new();
+
     source_rc_file(rc_file);
 
-    file_history = file_history_new();
     file_history_load(file_history);
     file_history_trav(file_history, 0, add_to_readline_history);
 }