From 2de4db6a42080646a3bd83b8fa65a6aa58e271d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Groenvall?= Date: Wed, 27 Dec 1995 22:40:48 +0000 Subject: [PATCH] Add -x option to rcp. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@207 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/des/enc_read.c | 14 ++++++++------ lib/des/enc_writ.c | 31 ++++++++++++++++++------------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/lib/des/enc_read.c b/lib/des/enc_read.c index 0e91d0ea4..1f87fb741 100644 --- a/lib/des/enc_read.c +++ b/lib/des/enc_read.c @@ -5,6 +5,8 @@ #include #include "des_locl.h" +int LEFT_JUSTIFIED = 0; + /* This has some uglies in it but it works - even over sockets. */ extern int errno; int des_rw_mode=DES_PCBC_MODE; @@ -120,7 +122,10 @@ int des_enc_read(int fd, char *buf, int len, struct des_ks_struct *sched, des_cb /* eay 26/08/92 fix a bug that returned more * bytes than you asked for (returned len bytes :-( */ - memcpy(buf,tmpbuf,num); + if (LEFT_JUSTIFIED || (len >= 8)) + memcpy(buf,tmpbuf,num); + else + memcpy(buf,tmpbuf+(8-num),num); /* Right justified */ } else if (num >= 8) { @@ -143,11 +148,8 @@ int des_enc_read(int fd, char *buf, int len, struct des_ks_struct *sched, des_cb des_cbc_encrypt((des_cblock *)net, (des_cblock *)buf,8,sched,iv, DES_DECRYPT); -#ifdef LEFT_JUSTIFIED - memcpy(buf, buf, num); -#else - memcpy(buf, buf+(8-num), num); -#endif + if (!LEFT_JUSTIFIED) + memcpy(buf, buf+(8-num), num); /* Right justified */ } } return(num); diff --git a/lib/des/enc_writ.c b/lib/des/enc_writ.c index 220c1b790..1ad8c3bc3 100644 --- a/lib/des/enc_writ.c +++ b/lib/des/enc_writ.c @@ -5,6 +5,8 @@ #include #include "des_locl.h" +extern int LEFT_JUSTIFIED; + int des_enc_write(int fd, char *buf, int len, struct des_ks_struct *sched, des_cblock (*iv)) { long rnum; @@ -45,19 +47,22 @@ int des_enc_write(int fd, char *buf, int len, struct des_ks_struct *sched, des_c /* pad short strings */ if (len < 8) { -#ifdef LEFT_JUSTIFIED - p=shortbuf; - memcpy(shortbuf,buf,len); - for (i=len; i<8; i++) - shortbuf[i]=rand(); - rnum=8; -#else - p=shortbuf; - for (i=0; i<8-len; i++) - shortbuf[i]=rand(); - memcpy(shortbuf + 8 - len, buf, len); - rnum=8; -#endif + if (LEFT_JUSTIFIED) + { + p=shortbuf; + memcpy(shortbuf,buf,len); + for (i=len; i<8; i++) + shortbuf[i]=rand(); + rnum=8; + } + else + { + p=shortbuf; + for (i=0; i<8-len; i++) + shortbuf[i]=rand(); + memcpy(shortbuf + 8 - len, buf, len); + rnum=8; + } } else {