Skip to content

Commit 525e60b

Browse files
committed
Fix compilation of uuid-ossp
This module had a dependency on pgcrypto's md5.c that got removed by b67b57a. Instead of the code from pgcrypto, this code can just use the new cryptohash routines for MD5 as a drop-in replacement, so let's just do this switch. This has also the merit to simplify a bit the compilation of uuid-ossp. This requires --with-uuid to be reproduced, and I have used e2fs as a way to reproduce the failure, then test this commit. Per reports from buildfarm members longfin, florican and sifaka. Discussion: https://postgr.es/m/X9GToVd3QmWeNvj8@paquier.xyz
1 parent b67b57a commit 525e60b

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

configure

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8307,12 +8307,12 @@ if test "$with_uuid" = bsd ; then
83078307

83088308
$as_echo "#define HAVE_UUID_BSD 1" >>confdefs.h
83098309

8310-
UUID_EXTRA_OBJS="md5.o sha1.o"
8310+
UUID_EXTRA_OBJS="sha1.o"
83118311
elif test "$with_uuid" = e2fs ; then
83128312

83138313
$as_echo "#define HAVE_UUID_E2FS 1" >>confdefs.h
83148314

8315-
UUID_EXTRA_OBJS="md5.o sha1.o"
8315+
UUID_EXTRA_OBJS="sha1.o"
83168316
elif test "$with_uuid" = ossp ; then
83178317

83188318
$as_echo "#define HAVE_UUID_OSSP 1" >>confdefs.h

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,10 +921,10 @@ fi
921921

922922
if test "$with_uuid" = bsd ; then
923923
AC_DEFINE([HAVE_UUID_BSD], 1, [Define to 1 if you have BSD UUID support.])
924-
UUID_EXTRA_OBJS="md5.o sha1.o"
924+
UUID_EXTRA_OBJS="sha1.o"
925925
elif test "$with_uuid" = e2fs ; then
926926
AC_DEFINE([HAVE_UUID_E2FS], 1, [Define to 1 if you have E2FS UUID support.])
927-
UUID_EXTRA_OBJS="md5.o sha1.o"
927+
UUID_EXTRA_OBJS="sha1.o"
928928
elif test "$with_uuid" = ossp ; then
929929
AC_DEFINE([HAVE_UUID_OSSP], 1, [Define to 1 if you have OSSP UUID support.])
930930
UUID_EXTRA_OBJS=""

contrib/uuid-ossp/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pgcrypto_src = $(top_srcdir)/contrib/pgcrypto
1919

2020
PG_CPPFLAGS = -I$(pgcrypto_src)
2121

22-
EXTRA_CLEAN = md5.c sha1.c
22+
EXTRA_CLEAN = sha1.c
2323

2424
ifdef USE_PGXS
2525
PG_CONFIG = pg_config
@@ -32,5 +32,5 @@ include $(top_builddir)/src/Makefile.global
3232
include $(top_srcdir)/contrib/contrib-global.mk
3333
endif
3434

35-
md5.c sha1.c: % : $(pgcrypto_src)/%
35+
sha1.c: % : $(pgcrypto_src)/%
3636
rm -f $@ && $(LN_S) $< .

contrib/uuid-ossp/uuid-ossp.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "postgres.h"
1515

1616
#include "fmgr.h"
17+
#include "common/cryptohash.h"
1718
#include "port/pg_bswap.h"
1819
#include "utils/builtins.h"
1920
#include "utils/uuid.h"
@@ -44,7 +45,6 @@
4445
* so we use a copy of the ones from pgcrypto. Not needed with OSSP, though.
4546
*/
4647
#ifndef HAVE_UUID_OSSP
47-
#include "md5.h"
4848
#include "sha1.h"
4949
#endif
5050

@@ -324,13 +324,17 @@ uuid_generate_internal(int v, unsigned char *ns, const char *ptr, int len)
324324

325325
if (v == 3)
326326
{
327-
MD5_CTX ctx;
327+
pg_cryptohash_ctx *ctx = pg_cryptohash_create(PG_MD5);
328328

329-
MD5Init(&ctx);
330-
MD5Update(&ctx, ns, sizeof(uu));
331-
MD5Update(&ctx, (unsigned char *) ptr, len);
329+
if (pg_cryptohash_init(ctx) < 0)
330+
elog(ERROR, "could not initialize %s context", "MD5");
331+
if (pg_cryptohash_update(ctx, ns, sizeof(uu)) < 0 ||
332+
pg_cryptohash_update(ctx, (unsigned char *) ptr, len) < 0)
333+
elog(ERROR, "could not update %s context", "MD5");
332334
/* we assume sizeof MD5 result is 16, same as UUID size */
333-
MD5Final((unsigned char *) &uu, &ctx);
335+
if (pg_cryptohash_final(ctx, (unsigned char *) &uu) < 0)
336+
elog(ERROR, "could not finalize %s context", "MD5");
337+
pg_cryptohash_free(ctx);
334338
}
335339
else
336340
{

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