[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

src/usr.bin/tn3270/api/api_bsd.c getpass() NULL check



As well as a few other things.

	- Jared

Index: api/api_bsd.c
===================================================================
RCS file: /cvs/src/usr.bin/tn3270/api/api_bsd.c,v
retrieving revision 1.4
diff -u -r1.4 api_bsd.c
--- api/api_bsd.c	2003/06/03 02:56:18	1.4
+++ api/api_bsd.c	2003/11/13 05:35:47
@@ -42,6 +42,8 @@
 #include <netdb.h>
 #include <stdio.h>
 #include <string.h>
+#include <pwd.h>
+#include <unistd.h>
 
 #include "../ctlr/api.h"
 #include "api_exch.h"
@@ -120,7 +122,7 @@
 	return -1;
     }
     keyfile = fopen(keyname, "r");
-    if (keyfile == 0) {
+    if (keyfile == NULL) {
 	perror("fopen");
 	return -1;
     }
@@ -128,6 +130,7 @@
 	perror("fscanf");
 	return -1;
     }
+    fclose(keyfile);
     sd.length = strlen(inkey)+1;
     if (api_exch_outtype(EXCH_TYPE_STORE_DESC, sizeof sd, (char *)&sd) == -1) {
 	return -1;
@@ -137,7 +140,7 @@
     }
     while ((i = api_exch_nextcommand()) != EXCH_CMD_ASSOCIATED) {
 	int passwd_length;
-	char *passwd, *getpass();
+	char *passwd;
 	char buffer[200];
 
 	switch (i) {
@@ -163,7 +166,8 @@
 		return -1;
 	    }
 	    buffer[sd.length] = 0;
-	    passwd = getpass(buffer);		/* Go to terminal */
+	    if ((passwd = getpass(buffer)) == NULL) /* Go to terminal */
+	    	perror("getpass");
 	    passwd_length = strlen(passwd);
 	    if (api_exch_intype(EXCH_TYPE_STORE_DESC, sizeof sd, (char *)&sd) == -1) {
 		return -1;



Visit your host, monkey.org