From: leslie Date: Thu, 3 Jan 2008 16:08:06 +0000 (+0100) Subject: made RotateBytes robust against bad input X-Git-Tag: 0.8.7~20 X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=33f046204c27b23f17d33487b35709c6a04f67a4;p=sasc-ng.git made RotateBytes robust against bad input --- diff --git a/crypto.c b/crypto.c index c1e64cc..a6c5bb4 100644 --- a/crypto.c +++ b/crypto.c @@ -29,22 +29,22 @@ void RotateBytes(unsigned char *out, const unsigned char *in, int n) { - // loop is executed atleast once, so it's not a good idea to - // call with n=0 !! - out+=n; - do { *(--out)=*(in++); } while(--n); + if(n>0) { + out+=n; + do { *(--out)=*(in++); } while(--n); + } } void RotateBytes(unsigned char *in, int n) { - // loop is executed atleast once, so it's not a good idea to - // call with n=0 !! - unsigned char *e=in+n-1; - do { - unsigned char temp=*in; - *in++=*e; - *e-- =temp; - } while(in1) { + unsigned char *e=in+n-1; + do { + unsigned char temp=*in; + *in++=*e; + *e-- =temp; + } while(in