-
-
Notifications
You must be signed in to change notification settings - Fork 499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rfbEncryptAndStorePasswd: fail if encryption fails #611
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,10 @@ rfbEncryptAndStorePasswd(char *passwd, char *fname) | |
|
||
/* Do encryption in-place - this way we overwrite our copy of the plaintext | ||
password */ | ||
encrypt_rfbdes(encryptedPasswd, &out_len, fixedkey, encryptedPasswd, sizeof(encryptedPasswd)); | ||
if (encrypt_rfbdes(encryptedPasswd, &out_len, fixedkey, encryptedPasswd, sizeof(encryptedPasswd)) == 0) { | ||
chhitz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fclose(fp); | ||
return 1; | ||
} | ||
|
||
for (i = 0; i < 8; i++) { | ||
putc(encryptedPasswd[i], fp); | ||
|
@@ -180,7 +183,7 @@ rfbRandomBytes(unsigned char *bytes) | |
* Encrypt CHALLENGESIZE bytes in memory using a password. | ||
*/ | ||
|
||
void | ||
int | ||
rfbEncryptBytes(unsigned char *bytes, char *passwd) | ||
{ | ||
unsigned char key[8]; | ||
|
@@ -197,19 +200,27 @@ rfbEncryptBytes(unsigned char *bytes, char *passwd) | |
} | ||
} | ||
|
||
encrypt_rfbdes(bytes, &out_len, key, bytes, CHALLENGESIZE); | ||
if (encrypt_rfbdes(bytes, &out_len, key, bytes, CHALLENGESIZE) == 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe just return the return value of encrypt_rfbdes() or use a ternary op? |
||
return 1; | ||
} | ||
return 0; | ||
} | ||
|
||
void | ||
int | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment here about return value semantics would be good! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, maybe rfbBool? |
||
rfbEncryptBytes2(unsigned char *where, const int length, unsigned char *key) { | ||
int i, j, out_len; | ||
for (i = 0; i< 8; i++) | ||
where[i] ^= key[i]; | ||
encrypt_rfbdes(where, &out_len, key, where, 8); | ||
if (encrypt_rfbdes(where, &out_len, key, where, 8) == 0) { | ||
return 1; | ||
} | ||
for (i = 8; i < length; i += 8) { | ||
for (j = 0; j < 8; j++) { | ||
where[i + j] ^= where[i + j - 8]; | ||
} | ||
encrypt_rfbdes(where + i, &out_len, key, where + i, 8); | ||
if (encrypt_rfbdes(where + i, &out_len, key, where + i, 8) == 0) { | ||
return 1; | ||
} | ||
} | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API change but I think it's OK ABI-wise. https://stackoverflow.com/questions/15626579/c-abi-is-changing-a-void-function-to-return-an-int-a-breaking-change also indicates so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the semantics of the return value? If it's boolean why not use the rfbBool type?