Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita61095a

Browse files
committed
Reject bogus output from uuid_create(3).
When using the BSD UUID functions, contrib/uuid-ossp expectsuuid_create() to produce a version-1 UUID. FreeBSD still does so,but in recent NetBSD releases that function produces a version-4(random) UUID instead. That's not acceptable for our purposes:if the user wanted v4 she would have asked for v4, not v1.Hence, check the version digit and complain if it's not '1'.Also drop the documentation's claim that the NetBSD implementationis usable. It might be, depending on which OS version you're using,but we're not going to get into that kind of detail.(Maybe someday we should ditch all these external librariesand just write our own UUID code, but today is not that day.)Nazir Bilal Yavuz, with cosmetic adjustments and docs by me.Backpatch to all supported versions.Discussion:https://postgr.es/m/3848059.1661038772@sss.pgh.pa.usDiscussion:https://postgr.es/m/17358-89806e7420797025@postgresql.org
1 parent80ef25b commita61095a

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

‎contrib/uuid-ossp/uuid-ossp.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,18 @@ uuid_generate_internal(int v, unsigned char *ns, const char *ptr, int len)
292292
{
293293
strlcpy(strbuf,str,37);
294294

295+
/*
296+
* In recent NetBSD, uuid_create() has started
297+
* producing v4 instead of v1 UUIDs. Check the
298+
* version field and complain if it's not v1.
299+
*/
300+
if (strbuf[14]!='1')
301+
ereport(ERROR,
302+
(errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
303+
/* translator: %c will be a hex digit */
304+
errmsg("uuid_create() produced a version %c UUID instead of the expected version 1",
305+
strbuf[14])));
306+
295307
/*
296308
* PTR, if set, replaces the trailing characters of
297309
* the uuid; this is to support v1mc, where a random

‎doc/src/sgml/installation.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ build-postgresql:
10911091
<itemizedlist>
10921092
<listitem>
10931093
<para>
1094-
<option>bsd</option> to use the UUID functions found in FreeBSD, NetBSD,
1094+
<option>bsd</option> to use the UUID functions found in FreeBSD
10951095
and some other BSD-derived systems
10961096
</para>
10971097
</listitem>

‎doc/src/sgml/uuid-ossp.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ SELECT uuid_generate_v3(uuid_ns_url(), 'http://www.postgresql.org');
213213
at <ulink url="http://www.ossp.org/pkg/lib/uuid/"></ulink>, it is not well
214214
maintained, and is becoming increasingly difficult to port to newer
215215
platforms. <filename>uuid-ossp</filename> can now be built without the OSSP
216-
library on some platforms. On FreeBSD, NetBSD, and some other BSD-derived
216+
library on some platforms. On FreeBSD and some other BSD-derived
217217
platforms, suitable UUID creation functions are included in the
218218
core <filename>libc</filename> library. On Linux, macOS, and some other
219219
platforms, suitable functions are provided in the <filename>libuuid</filename>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp