]> granicus.if.org Git - postgresql/commitdiff
Fix error detection in contrib/pgcrypto's encrypt_iv() and decrypt_iv().
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 28 Jan 2012 04:09:16 +0000 (23:09 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 28 Jan 2012 04:09:33 +0000 (23:09 -0500)
Due to oversights, the encrypt_iv() and decrypt_iv() functions failed to
report certain types of invalid-input errors, and would instead return
random garbage values.

Marko Kreen, per report from Stefan Kaltenbrunner

contrib/pgcrypto/pgcrypto.c

index d271ddc30296db7831be61891e57f31b4b35ca0f..1da3afcd1d8d712932fcb4f653e22fdcdde318ed 100644 (file)
@@ -342,8 +342,8 @@ pg_encrypt_iv(PG_FUNCTION_ARGS)
        err = px_combo_init(c, (uint8 *) VARDATA(key), klen,
                                                (uint8 *) VARDATA(iv), ivlen);
        if (!err)
-               px_combo_encrypt(c, (uint8 *) VARDATA(data), dlen,
-                                                (uint8 *) VARDATA(res), &rlen);
+               err = px_combo_encrypt(c, (uint8 *) VARDATA(data), dlen,
+                                                          (uint8 *) VARDATA(res), &rlen);
 
        px_combo_free(c);
 
@@ -396,8 +396,8 @@ pg_decrypt_iv(PG_FUNCTION_ARGS)
        err = px_combo_init(c, (uint8 *) VARDATA(key), klen,
                                                (uint8 *) VARDATA(iv), ivlen);
        if (!err)
-               px_combo_decrypt(c, (uint8 *) VARDATA(data), dlen,
-                                                (uint8 *) VARDATA(res), &rlen);
+               err = px_combo_decrypt(c, (uint8 *) VARDATA(data), dlen,
+                                                          (uint8 *) VARDATA(res), &rlen);
 
        px_combo_free(c);