Skip to content

Commit 02a75f8

Browse files
committed
Add missing error check in pgcrypto/crypt-md5.c.
In theory, the second px_find_digest call in px_crypt_md5 could fail even though the first one succeeded, since resource allocation is required. Don't skip testing for a failure. (If one did happen, the likely result would be a crash rather than clean recovery from an OOM failure.) The code's been like this all along, so back-patch to all supported branches. Daniel Gustafsson Discussion: https://postgr.es/m/AA8D6FE9-4AB2-41B4-98CB-AE64BA668C03@yesql.se
1 parent bc49f87 commit 02a75f8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

contrib/pgcrypto/crypt-md5.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,17 @@ px_crypt_md5(const char *pw, const char *salt, char *passwd, unsigned dstlen)
6565
/* get the length of the true salt */
6666
sl = ep - sp;
6767

68-
/* */
68+
/* we need two PX_MD objects */
6969
err = px_find_digest("md5", &ctx);
7070
if (err)
7171
return NULL;
7272
err = px_find_digest("md5", &ctx1);
73+
if (err)
74+
{
75+
/* this path is possible under low-memory circumstances */
76+
px_md_free(ctx);
77+
return NULL;
78+
}
7379

7480
/* The password first, since that is what is most unknown */
7581
px_md_update(ctx, (const uint8 *) pw, strlen(pw));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy