Commit 7fe0ba3c by Enrico Pozzobon

fixed new knot implementation memset overflow

parent 694fe7f9
...@@ -237,8 +237,8 @@ int crypto_aead_decrypt(unsigned char *m, unsigned long long *mlen, ...@@ -237,8 +237,8 @@ int crypto_aead_decrypt(unsigned char *m, unsigned long long *mlen,
unpackFormat(tempU8, s); unpackFormat(tempU8, s);
unpackFormat((tempU8+8), (s+2)); unpackFormat((tempU8+8), (s+2));
if (memcmp((void*)tempU8, (void*)c,CRYPTO_ABYTES)) { if (memcmp((void*)tempU8, (void*)c,CRYPTO_ABYTES)) {
memset(m, 0, sizeof(unsigned char) * (*mlen));
*mlen = 0; *mlen = 0;
memset(m, 0, sizeof(unsigned char) * (clen - CRYPTO_ABYTES));
return -1; return -1;
} }
return 0; return 0;
......
...@@ -248,8 +248,8 @@ int crypto_aead_decrypt(unsigned char *m, unsigned long long *mlen, ...@@ -248,8 +248,8 @@ int crypto_aead_decrypt(unsigned char *m, unsigned long long *mlen,
unpackU96FormatToThreePacket(tempU8, s); unpackU96FormatToThreePacket(tempU8, s);
unpackU96FormatToThreePacket((tempU8 + 12), (s + 3)); unpackU96FormatToThreePacket((tempU8 + 12), (s + 3));
if (memcmp((void*)tempU8, (void*)c, CRYPTO_ABYTES)) { if (memcmp((void*)tempU8, (void*)c, CRYPTO_ABYTES)) {
memset(m, 0, sizeof(unsigned char) * (*mlen));
*mlen = 0; *mlen = 0;
memset(m, 0, sizeof(unsigned char) * (clen - CRYPTO_ABYTES));
return -1; return -1;
} }
return 0; return 0;
......
...@@ -202,8 +202,8 @@ int crypto_aead_decrypt(unsigned char *m, unsigned long long *mlen, ...@@ -202,8 +202,8 @@ int crypto_aead_decrypt(unsigned char *m, unsigned long long *mlen,
unpackU96FormatToThreePacket(tempU8, s); unpackU96FormatToThreePacket(tempU8, s);
unpackU96FormatToThreePacket((tempU8 + 12), (s + 3)); unpackU96FormatToThreePacket((tempU8 + 12), (s + 3));
if (memcmp((void*)tempU8, (void*)c, CRYPTO_ABYTES)) { if (memcmp((void*)tempU8, (void*)c, CRYPTO_ABYTES)) {
memset(m, 0, sizeof(unsigned char) * (*mlen));
*mlen = 0; *mlen = 0;
memset(m, 0, sizeof(unsigned char) * (clen - CRYPTO_ABYTES));
return -1; return -1;
} }
return 0; return 0;
......
...@@ -320,8 +320,8 @@ int crypto_aead_decrypt( ...@@ -320,8 +320,8 @@ int crypto_aead_decrypt(
unpackU128FormatToFourPacket(tempU8, s); unpackU128FormatToFourPacket(tempU8, s);
unpackU128FormatToFourPacket((tempU8 + 16), (s + 4)); unpackU128FormatToFourPacket((tempU8 + 16), (s + 4));
if (memcmp((void*)tempU8, (void*)c, CRYPTO_ABYTES)) { if (memcmp((void*)tempU8, (void*)c, CRYPTO_ABYTES)) {
memset(m, 0, sizeof(unsigned char) * (*mlen));
*mlen = 0; *mlen = 0;
memset(m, 0, sizeof(unsigned char) * (clen - CRYPTO_ABYTES));
return -1; return -1;
} }
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment