git.stg.codes
/
stg.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(from parent 1:
76d211b
)
Handle short string correctly in blowfish encription.
author
Maxim Mamontov
<faust.madf@gmail.com>
Sat, 13 Sep 2014 21:56:48 +0000
(
00:56
+0300)
committer
Maxim Mamontov
<faust.madf@gmail.com>
Sat, 13 Sep 2014 21:56:48 +0000
(
00:56
+0300)
stglibs/crypto.lib/blowfish.c
patch
|
blob
|
history
diff --git
a/stglibs/crypto.lib/blowfish.c
b/stglibs/crypto.lib/blowfish.c
index 90c93b9da3d27ca5cd78ac63917783ddbed29bfc..e2f275e6275b0322bab7536093245fdb263e6143 100644
(file)
--- a/
stglibs/crypto.lib/blowfish.c
+++ b/
stglibs/crypto.lib/blowfish.c
@@
-504,7
+504,16
@@
void EncryptString(void * d, const void * s, size_t length, const BLOWFISH_CTX *
size_t pos = 0;
while (pos < length)
{
- EncryptBlock(d + pos, s + pos, ctx);
+ if (pos + 8 < length)
+ EncryptBlock(d + pos, s + pos, ctx);
+ else
+ {
+ // Short string, use 0-padded buffer.
+ char buf[8];
+ memset(buf, 0, sizeof(buf));
+ memcpy(buf, s + pos, length - pos);
+ EncryptBlock(d + pos, buf, ctx);
+ }
pos += 8;
}
}