Bug 1397630 - fix blake2b coverity issue, r=ttaubert
authorFranziskus Kiefer <franziskuskiefer@gmail.com>
Thu, 07 Sep 2017 10:39:06 +0200
changeset 13570 d839b28bc4fee96b48cace984dad4d137d802c01
parent 13569 69242366eb810294a1d8e512e60732d832fd3c8a
child 13571 0ba9a65e3f156526e8eb9c121a4c89c6afbea7bc
push id2358
push userfranziskuskiefer@gmail.com
push dateThu, 07 Sep 2017 08:40:38 +0000
reviewersttaubert
bugs1397630
Bug 1397630 - fix blake2b coverity issue, r=ttaubert Bug #: 1397630 Differential Revision: https://phabricator.services.mozilla.com/D36
lib/freebl/blake2b.c
--- a/lib/freebl/blake2b.c
+++ b/lib/freebl/blake2b.c
@@ -274,24 +274,24 @@ BLAKE2B_Update(BLAKE2BContext* ctx, cons
  */
 SECStatus
 BLAKE2B_End(BLAKE2BContext* ctx, unsigned char* out,
             unsigned int* digestLen, size_t maxDigestLen)
 {
     size_t i;
     unsigned int outlen = PR_MIN(BLAKE2B512_LENGTH, maxDigestLen);
 
-    /* Sanity check against outlen in context. */
-    if (ctx->outlen < outlen) {
+    /* Argument checks */
+    if (!ctx || !out) {
         PORT_SetError(SEC_ERROR_INVALID_ARGS);
         return SECFailure;
     }
 
-    /* Argument checks */
-    if (!ctx || !out) {
+    /* Sanity check against outlen in context. */
+    if (ctx->outlen < outlen) {
         PORT_SetError(SEC_ERROR_INVALID_ARGS);
         return SECFailure;
     }
 
     /* Is this a reused context? */
     if (ctx->f != 0) {
         PORT_SetError(SEC_ERROR_INVALID_ARGS);
         return SECFailure;