diff options
author | Wan-Teh Chang <wtc@google.com> | 2013-03-28 13:31:49 -0700 |
---|---|---|
committer | Wan-Teh Chang <wtc@google.com> | 2013-03-28 13:31:49 -0700 |
commit | 5a83775fd5d5bb0ec8e29b5c4a1339599c158446 (patch) | |
tree | c48b1860ef1a3ad4b04485281795306994443c6f | |
parent | f98f3e2657ac24f0baf835ab7bffee3f35504fd9 (diff) | |
download | nss-hg-5a83775fd5d5bb0ec8e29b5c4a1339599c158446.tar.gz |
Bug 853285: Don't call PORT_Memcpy with a NULL source buffer pointer.
Use a better error code when the input buffer is too short. r=sleevi.
-rw-r--r-- | lib/freebl/gcm.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/freebl/gcm.c b/lib/freebl/gcm.c index a3de54783..a62dd8db3 100644 --- a/lib/freebl/gcm.c +++ b/lib/freebl/gcm.c @@ -453,7 +453,9 @@ gcmHash_Update(gcmHashContext *ghash, const unsigned char *buf, * we can hash it */ if (ghash->bufLen) { unsigned int needed = PR_MIN(len, blocksize - ghash->bufLen); - PORT_Memcpy(ghash->buffer+ghash->bufLen, buf, needed); + if (needed != 0) { + PORT_Memcpy(ghash->buffer+ghash->bufLen, buf, needed); + } buf += needed; len -= needed; ghash->bufLen += needed; @@ -814,7 +816,7 @@ GCM_DecryptUpdate(GCMContext *gcm, unsigned char *outbuf, /* get the authentication block */ if (inlen < tagBytes) { - PORT_SetError(SEC_ERROR_INVALID_ARGS); + PORT_SetError(SEC_ERROR_INPUT_LEN); return SECFailure; } |