@@ -102,7 +102,10 @@ rfbEncryptAndStorePasswd(char *passwd, char *fname)
102
102
103
103
/* Do encryption in-place - this way we overwrite our copy of the plaintext
104
104
password */
105
- encrypt_rfbdes (encryptedPasswd , & out_len , fixedkey , encryptedPasswd , sizeof (encryptedPasswd ));
105
+ if (encrypt_rfbdes (encryptedPasswd , & out_len , fixedkey , encryptedPasswd , sizeof (encryptedPasswd )) == 0 ) {
106
+ fclose (fp );
107
+ return 1 ;
108
+ }
106
109
107
110
for (i = 0 ; i < 8 ; i ++ ) {
108
111
putc (encryptedPasswd [i ], fp );
@@ -180,7 +183,7 @@ rfbRandomBytes(unsigned char *bytes)
180
183
* Encrypt CHALLENGESIZE bytes in memory using a password.
181
184
*/
182
185
183
- void
186
+ int
184
187
rfbEncryptBytes (unsigned char * bytes , char * passwd )
185
188
{
186
189
unsigned char key [8 ];
@@ -197,19 +200,30 @@ rfbEncryptBytes(unsigned char *bytes, char *passwd)
197
200
}
198
201
}
199
202
200
- encrypt_rfbdes (bytes , & out_len , key , bytes , CHALLENGESIZE );
203
+ if (encrypt_rfbdes (bytes , & out_len , key , bytes , CHALLENGESIZE ) == 0 ) {
204
+ fclose (fp );
205
+ return 1 ;
206
+ }
207
+ return 0 ;
201
208
}
202
209
203
- void
210
+ int
204
211
rfbEncryptBytes2 (unsigned char * where , const int length , unsigned char * key ) {
205
212
int i , j , out_len ;
206
213
for (i = 0 ; i < 8 ; i ++ )
207
214
where [i ] ^= key [i ];
208
- encrypt_rfbdes (where , & out_len , key , where , 8 );
215
+ if (encrypt_rfbdes (where , & out_len , key , where , 8 ) == 0 ) {
216
+ fclose (fp );
217
+ return 1 ;
218
+ }
209
219
for (i = 8 ; i < length ; i += 8 ) {
210
220
for (j = 0 ; j < 8 ; j ++ ) {
211
221
where [i + j ] ^= where [i + j - 8 ];
212
222
}
213
- encrypt_rfbdes (where + i , & out_len , key , where + i , 8 );
223
+ if (encrypt_rfbdes (where + i , & out_len , key , where + i , 8 ) == 0 ) {
224
+ fclose (fp );
225
+ return 1 ;
226
+ }
214
227
}
228
+ return 0 ;
215
229
}
0 commit comments