@@ -359,7 +359,11 @@ Item *RemoteDirList(const char *dirname, bool encrypt, AgentConnection *conn)
359359
360360 tosend = cipherlen + CF_PROTO_OFFSET ;
361361
362- if (tosend > sizeof (sendbuffer ))
362+ if (tosend < 0 )
363+ {
364+ ProgrammingError ("RemoteDirList: tosend (%d) < 0" , tosend );
365+ }
366+ else if ((unsigned long ) tosend > sizeof (sendbuffer ))
363367 {
364368 ProgrammingError ("RemoteDirList: tosend (%d) > sendbuffer (%zd)" ,
365369 tosend , sizeof (sendbuffer ));
@@ -495,7 +499,11 @@ bool CompareHashNet(const char *file1, const char *file2, bool encrypt, AgentCon
495499
496500 tosend = cipherlen + CF_PROTO_OFFSET ;
497501
498- if (tosend > sizeof (sendbuffer ))
502+ if (tosend < 0 )
503+ {
504+ ProgrammingError ("CompareHashNet: tosend (%d) < 0" , tosend );
505+ }
506+ else if ((unsigned long ) tosend > sizeof (sendbuffer ))
499507 {
500508 ProgrammingError ("CompareHashNet: tosend (%d) > sendbuffer (%zd)" ,
501509 tosend , sizeof (sendbuffer ));
@@ -589,7 +597,11 @@ static bool EncryptCopyRegularFileNet(const char *source, const char *dest, off_
589597
590598 tosend = cipherlen + CF_PROTO_OFFSET ;
591599
592- if (tosend > sizeof (workbuf ))
600+ if (tosend < 0 )
601+ {
602+ ProgrammingError ("EncryptCopyRegularFileNet: tosend (%d) < 0" , tosend );
603+ }
604+ else if ((unsigned long ) tosend > sizeof (workbuf ))
593605 {
594606 ProgrammingError ("EncryptCopyRegularFileNet: tosend (%d) > workbuf (%zd)" ,
595607 tosend , sizeof (workbuf ));
0 commit comments