shishi-commit
[Top][All Lists]
Advanced

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

inetutils/libinetutils shishi.c


From: shishi-commit
Subject: inetutils/libinetutils shishi.c
Date: Wed, 17 Sep 2003 16:35:40 -0400

CVSROOT:        /cvsroot/shishi
Module name:    inetutils
Branch:         
Changes by:     Nicolas Pouvesle <address@hidden>       03/09/17 16:35:40

Modified files:
        libinetutils   : shishi.c 

Log message:
        Cleanup.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/inetutils/libinetutils/shishi.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: inetutils/libinetutils/shishi.c
diff -u inetutils/libinetutils/shishi.c:1.2 inetutils/libinetutils/shishi.c:1.3
--- inetutils/libinetutils/shishi.c:1.2 Wed Sep 17 09:16:52 2003
+++ inetutils/libinetutils/shishi.c     Wed Sep 17 16:35:40 2003
@@ -101,7 +101,7 @@
 
   memset (&hint, 0, sizeof (hint));
 
-  tmpserver = xmalloc (strlen(SERVICE) + strlen(sname) + 2);
+  tmpserver = (char *)xmalloc (strlen(SERVICE) + strlen(sname) + 2);
   strcpy (tmpserver, SERVICE);
   strcat (tmpserver, "/");
   strcat (tmpserver, sname);
@@ -236,7 +236,6 @@
   int rc;
   int i;
   int error;
-  char result;
   /* KERBEROS 5 SENDAUTH MESSAGE */
   char krb5sendauth[] = "KRB5_SENDAUTH_V1.0";
   /* PROTOCOL VERSION */
@@ -334,8 +333,7 @@
   
   /* Authentication type is ok */
 
-  result = '\0';
-  write (infd, &result, 1);
+  write (infd, "\0", 1);
 
   /* Read Authentication request from client */
 
@@ -467,9 +465,9 @@
 readenc (Shishi * h, int sock, char *buf, int *len, shishi_ivector *iv,
         Shishi_key * enckey, int proto)
 {
-  char *out;
-  char *outbis;
-  char *iv2;
+  char * out;
+  char * outbis;
+  char * iv2;
 
   int rc;
   int val;
@@ -497,7 +495,7 @@
   dlen += blocksize - 1;
   if (proto == 2)
     dlen += 4;
-  if (shishi_key_type (enckey) != SHISHI_DES3_CBC_HMAC_SHA1_KD)
+  if (enctype != SHISHI_DES3_CBC_HMAC_SHA1_KD)
     dlen += hashsize;
   else
     dlen += blocksize;
@@ -505,11 +503,11 @@
   dlen /= blocksize;
   dlen *= blocksize;
 
-  if (shishi_key_type (enckey) == SHISHI_DES3_CBC_HMAC_SHA1_KD)
+  if (enctype == SHISHI_DES3_CBC_HMAC_SHA1_KD)
     dlen += hashsize;
 
   /* read encrypted data */
-  outbis = malloc (dlen);
+  outbis = (char *)xmalloc (dlen);
   if (outbis == NULL)
     {
       printf ("Malloc error!\n");
@@ -520,6 +518,7 @@
   if (rc != dlen)
     {
       printf ("Error during read socket\n");
+      free (outbis);
       return 1;
     }
   
@@ -527,34 +526,32 @@
     { 
       rc =
        shishi_decrypt (h, enckey, iv->keyusage, outbis, dlen, &out, &outlen);
+      if (rc != SHISHI_OK)
+       {
+         printf ("decryption error\n");
+         free (outbis);
+         return 1;
+       }
+
+      *len = outlen;
+      val = 0;
     }
   else
     {
       rc =
        shishi_decrypt_ivupdate (h, enckey, iv->keyusage, iv->iv, iv->ivlen, 
&iv2, &iv->ivlen, outbis,
                             dlen, &out, &outlen);
-    }
-  if (rc != SHISHI_OK)
-    {
-      printf ("decryption error\n");
-      return 1;
-    }
+      if (rc != SHISHI_OK)
+       {
+         printf ("decryption error\n");
+         free (outbis);
+         return 1;
+       }
 
-  /* len = first 4 bytes of decrypted data */
-  if (proto == 2)
-    {
       /* in KCMDV0.2 first 4 bytes of decrypted data = len of data */
       *len = ntohl (*((int *) out));
       val = sizeof (int);
-    }
-  else
-    {
-      *len = outlen;
-      val = 0;
-    }
 
-  if (proto == 2)
-    {
       /* update iv */
       memcpy (iv->iv, iv2, iv->ivlen);
     }
@@ -591,8 +588,7 @@
   /* data to encrypt = size + data */
   if (proto == 2)
     {
-      bufbis = malloc (wlen + sizeof (int));
-      memset (bufbis, 0, wlen + sizeof (int));
+      bufbis = (char *)xmalloc (wlen + sizeof (int));
       memcpy (bufbis, (char *) &dlen, sizeof (int));
       memcpy (bufbis + sizeof (int), buf, wlen);
       
@@ -603,8 +599,7 @@
     }
   else
     {
-      bufbis = malloc (wlen);
-      memset (bufbis, 0, wlen);
+      bufbis = (char *)xmalloc (wlen);
       memcpy (bufbis, buf, wlen);
     
       /* data to encrypt = size + data */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]