krcp.c, krlogin.c, krlogind.c (v5_des_write): Fix byte swapping code
authorTheodore Tso <tytso@mit.edu>
Mon, 19 Dec 1994 20:15:08 +0000 (20:15 +0000)
committerTheodore Tso <tytso@mit.edu>
Mon, 19 Dec 1994 20:15:08 +0000 (20:15 +0000)
(Missing shift instructions).

krlogind.c: Fixed byte swapping code so that V4 des compatibility
works on 64 bit architectures.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4734 dc483132-0cff-0310-8789-dd5450dbe970

src/appl/bsd/ChangeLog
src/appl/bsd/krcp.c
src/appl/bsd/krlogin.c
src/appl/bsd/krlogind.c

index 8cab422d6a64c61f7ce911f68b8accf6e87804e9..b5fcb796c30921757983ee5a4f960023cbd8907a 100644 (file)
@@ -1,3 +1,14 @@
+Mon Dec 19 15:09:57 1994  Theodore Y. Ts'o  (tytso@dcl)
+
+       * krcp.c (des_write):
+       * krlogin.c (des_write):
+       * krlogind.c (v5_des_write): Fix byte swapping code (Missing shift
+               instructions).
+
+       * krlogind.c (v4_des_read, v4_des_write): Fixed byte swapping code
+               so that V4 des compatibility works on 64 bit
+               architectures.
+
 Fri Nov 18 01:19:13 1994  Mark Eichin  <eichin@cygnus.com>
 
        * Makefile.in (install): add install rules for krlogind.M,
index ccc05aa817d638bf0aa079275f1285da87df1aaa..fad1e559ce3185f14a558e2042b752b4ffdc3f94 100644 (file)
@@ -1467,9 +1467,9 @@ int des_write(fd, buf, len)
        return(-1);
     }
     
-    len_buf[0] = (len & 0xff000000);
-    len_buf[1] = (len & 0xff0000);
-    len_buf[2] = (len & 0xff00);
+    len_buf[0] = (len & 0xff000000) >> 24;
+    len_buf[1] = (len & 0xff0000) >> 16;
+    len_buf[2] = (len & 0xff00) >> 8;
     len_buf[3] = (len & 0xff);
     (void) write(fd, len_buf, 4);
     if (write(fd, desoutbuf.data,desoutbuf.length) != desoutbuf.length){
index d5d36680266329387c242497f4fe721462bb4b6b..1739fb2c7a9338b6b9c4c8df80ce868cbe97567f 100644 (file)
@@ -1753,9 +1753,9 @@ int des_write(fd, buf, len)
        return(-1);
     }
     
-    len_buf[0] = (len & 0xff000000);
-    len_buf[1] = (len & 0xff0000);
-    len_buf[2] = (len & 0xff00);
+    len_buf[0] = (len & 0xff000000) >> 24;
+    len_buf[1] = (len & 0xff0000) >> 16;
+    len_buf[2] = (len & 0xff00) >> 8;
     len_buf[3] = (len & 0xff);
     (void) write(fd, len_buf, 4);
     if (write(fd, desoutbuf.data,desoutbuf.length) != desoutbuf.length){
@@ -1882,9 +1882,9 @@ int des_write(fd, buf, len)
     
     /* tell the other end the real amount, but send an 8-byte padded
        packet */
-    len_buf[0] = (len & 0xff000000);
-    len_buf[1] = (len & 0xff0000);
-    len_buf[2] = (len & 0xff00);
+    len_buf[0] = (len & 0xff000000) >> 24;
+    len_buf[1] = (len & 0xff0000) >> 16;
+    len_buf[2] = (len & 0xff00) >> 8;
     len_buf[3] = (len & 0xff);
     (void) write(fd, len_buf, 4);
 #ifdef NOROUNDUP
index d8bd1f74656340c1e55a3d6fb3af8a3a7ccc7547..16bc6a852d6622b84d52237a09b882e5523cb69d 100644 (file)
@@ -879,7 +879,7 @@ char    oobdata[] = {0};
  */
 control(pty, cp, n)
      int pty;
-     char *cp;
+     unsigned char *cp;
      int n;
 {
     struct winsize w;
@@ -1259,7 +1259,7 @@ v5_des_read(fd, buf, len)
      int len;
 {
     int nreturned = 0;
-    long net_len,rd_len;
+    krb5_ui_4 net_len,rd_len;
     int cc,retry;
     unsigned char len_buf[4];
     
@@ -1364,9 +1364,9 @@ v5_des_write(fd, buf, len)
        return(-1);
     }
 
-    len_buf[0] = (len & 0xff000000);
-    len_buf[1] = (len & 0xff0000);
-    len_buf[2] = (len & 0xff00);
+    len_buf[0] = (len & 0xff000000) >> 24;
+    len_buf[1] = (len & 0xff0000) >> 16;
+    len_buf[2] = (len & 0xff00) >> 8;
     len_buf[3] = (len & 0xff);
     (void) write(fd, len_buf, 4);
     if (write(fd, desoutbuf.data,desoutbuf.length) != desoutbuf.length){
@@ -1634,8 +1634,9 @@ register char *buf;
 int len;
 {
        int nreturned = 0;
-       long net_len, rd_len;
+       krb5_ui_4 net_len, rd_len;
        int cc;
+       unsigned char len_buf[4];
 
        if (!do_encrypt)
                return(read(fd, buf, len));
@@ -1653,12 +1654,13 @@ int len;
                nstored = 0;
        }
        
-       if ((cc = krb_net_read(fd, &net_len, sizeof(net_len))) != sizeof(net_len)) {
+       if ((cc = krb_net_read(fd, (char *)&len_buf, 4)) != 4) {
                /* XXX can't read enough, pipe
                   must have closed */
                return(0);
        }
-       net_len = ntohl(net_len);
+       net_len = ((len_buf[0]<<24) | (len_buf[1]<<16) |
+                  (len_buf[2]<<8) | len_buf[3]);
        if (net_len < 0 || net_len > sizeof(des_inbuf)) {
                /* XXX preposterous length, probably out of sync.
                   act as if pipe closed */
@@ -1707,8 +1709,8 @@ int fd;
 char *buf;
 int len;
 {
-       long net_len;
        static char garbage_buf[8];
+       unsigned char len_buf[4];
 
        if (!do_encrypt)
                return(write(fd, buf, len));
@@ -1744,8 +1746,11 @@ int len;
 
        /* tell the other end the real amount, but send an 8-byte padded
           packet */
-       net_len = htonl(len);
-       (void) write(fd, &net_len, sizeof(net_len));
+       len_buf[0] = (len & 0xff000000) >> 24;
+       len_buf[1] = (len & 0xff0000) >> 16;
+       len_buf[2] = (len & 0xff00) >> 8;
+       len_buf[3] = (len & 0xff);
+       (void) write(fd, len_buf, 4);
        (void) write(fd, des_outbuf, roundup(len,8));
        return(len);
 }