[sword-cvs] sword/src/modules/filters cipherfil.cpp,1.15,1.16

sword@www.crosswire.org sword@www.crosswire.org
Sat, 19 Apr 2003 06:30:31 -0700


Update of /usr/local/cvsroot/sword/src/modules/filters
In directory www:/tmp/cvs-serv11220/src/modules/filters

Modified Files:
	cipherfil.cpp 
Log Message:
fix for an overflow in the cipher filter, by joachim

Index: cipherfil.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/cipherfil.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** cipherfil.cpp	1 Apr 2003 10:14:05 -0000	1.15
--- cipherfil.cpp	19 Apr 2003 13:30:28 -0000	1.16
***************
*** 27,36 ****
  
  char CipherFilter::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
! 	unsigned int len;
! //	len = strlen(text);
! 	len = text.length()-2;
  	if (len > 0) {
  		if (!key) {	// hack, using key to determine encipher, or decipher
! 			cipher->cipherBuf(&len, text);
  			//memcpy(text, cipher->Buf(), (len < (unsigned int)(maxlen)) ? len : maxlen);
  			text = cipher->Buf();
--- 27,34 ----
  
  char CipherFilter::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
! 	int len = text.length()-2; //not unsigned, this eould lead to an overflow if text.length() < 2
  	if (len > 0) {
  		if (!key) {	// hack, using key to determine encipher, or decipher
! 			cipher->cipherBuf(&(unsigned int)len, text);
  			//memcpy(text, cipher->Buf(), (len < (unsigned int)(maxlen)) ? len : maxlen);
  			text = cipher->Buf();
***************
*** 38,42 ****
  		else if ((unsigned long)key == 1) {
  			cipher->Buf(text, len);
! 			text = cipher->cipherBuf(&len);
  			//memcpy(text, cipher->cipherBuf(&len), (len < (unsigned int)(maxlen)) ? len : maxlen);
  		}
--- 36,40 ----
  		else if ((unsigned long)key == 1) {
  			cipher->Buf(text, len);
! 			text = cipher->cipherBuf(&(unsigned int)len);
  			//memcpy(text, cipher->cipherBuf(&len), (len < (unsigned int)(maxlen)) ? len : maxlen);
  		}