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

Commit4944852

Browse files
committed
Add missing return code checks in the uuid-ossp contrib module, per bug #3841.
1 parent7284dfe commit4944852

File tree

1 file changed

+53
-13
lines changed

1 file changed

+53
-13
lines changed

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

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright (c) 2007 PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/contrib/uuid-ossp/uuid-ossp.c,v 1.5 2007/11/15 22:25:14 momjian Exp $
7+
* $PostgreSQL: pgsql/contrib/uuid-ossp/uuid-ossp.c,v 1.6 2007/12/31 03:55:50 alvherre Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -64,15 +64,32 @@ PG_FUNCTION_INFO_V1(uuid_generate_v3);
6464
PG_FUNCTION_INFO_V1(uuid_generate_v4);
6565
PG_FUNCTION_INFO_V1(uuid_generate_v5);
6666

67+
staticvoid
68+
pguuid_complain(uuid_rc_trc)
69+
{
70+
char*err=uuid_error(rc);
71+
72+
if (err!=NULL)
73+
ereport(ERROR,
74+
(errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
75+
errmsg("OSSP uuid library failure: %s",err)));
76+
else
77+
ereport(ERROR,
78+
(errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
79+
errmsg("OSSP uuid library failure: error code %d",rc)));
80+
}
6781

6882
staticchar*
6983
uuid_to_string(constuuid_t*uuid)
7084
{
7185
char*buf=palloc(UUID_LEN_STR+1);
7286
void*ptr=buf;
7387
size_tlen=UUID_LEN_STR+1;
88+
uuid_rc_trc;
7489

75-
uuid_export(uuid,UUID_FMT_STR,&ptr,&len);
90+
rc=uuid_export(uuid,UUID_FMT_STR,&ptr,&len);
91+
if (rc!=UUID_RC_OK)
92+
pguuid_complain(rc);
7693

7794
returnbuf;
7895
}
@@ -81,7 +98,11 @@ uuid_to_string(const uuid_t * uuid)
8198
staticvoid
8299
string_to_uuid(constchar*str,uuid_t*uuid)
83100
{
84-
uuid_import(uuid,UUID_FMT_STR,str,UUID_LEN_STR+1);
101+
uuid_rc_trc;
102+
103+
rc=uuid_import(uuid,UUID_FMT_STR,str,UUID_LEN_STR+1);
104+
if (rc!=UUID_RC_OK)
105+
pguuid_complain(rc);
85106
}
86107

87108

@@ -90,11 +111,18 @@ special_uuid_value(const char *name)
90111
{
91112
uuid_t*uuid;
92113
char*str;
93-
94-
uuid_create(&uuid);
95-
uuid_load(uuid,name);
114+
uuid_rc_trc;
115+
116+
rc=uuid_create(&uuid);
117+
if (rc!=UUID_RC_OK)
118+
pguuid_complain(rc);
119+
rc=uuid_load(uuid,name);
120+
if (rc!=UUID_RC_OK)
121+
pguuid_complain(rc);
96122
str=uuid_to_string(uuid);
97-
uuid_destroy(uuid);
123+
rc=uuid_destroy(uuid);
124+
if (rc!=UUID_RC_OK)
125+
pguuid_complain(rc);
98126

99127
returnDirectFunctionCall1(uuid_in,CStringGetDatum(str));
100128
}
@@ -140,11 +168,18 @@ uuid_generate_internal(int mode, const uuid_t * ns, const char *name)
140168
{
141169
uuid_t*uuid;
142170
char*str;
143-
144-
uuid_create(&uuid);
145-
uuid_make(uuid,mode,ns,name);
171+
uuid_rc_trc;
172+
173+
rc=uuid_create(&uuid);
174+
if (rc!=UUID_RC_OK)
175+
pguuid_complain(rc);
176+
rc=uuid_make(uuid,mode,ns,name);
177+
if (rc!=UUID_RC_OK)
178+
pguuid_complain(rc);
146179
str=uuid_to_string(uuid);
147-
uuid_destroy(uuid);
180+
rc=uuid_destroy(uuid);
181+
if (rc!=UUID_RC_OK)
182+
pguuid_complain(rc);
148183

149184
returnDirectFunctionCall1(uuid_in,CStringGetDatum(str));
150185
}
@@ -169,16 +204,21 @@ uuid_generate_v35_internal(int mode, pg_uuid_t *ns, text *name)
169204
{
170205
uuid_t*ns_uuid;
171206
Datumresult;
207+
uuid_rc_trc;
172208

173-
uuid_create(&ns_uuid);
209+
rc=uuid_create(&ns_uuid);
210+
if (rc!=UUID_RC_OK)
211+
pguuid_complain(rc);
174212
string_to_uuid(DatumGetCString(DirectFunctionCall1(uuid_out,UUIDPGetDatum(ns))),
175213
ns_uuid);
176214

177215
result=uuid_generate_internal(mode,
178216
ns_uuid,
179217
DatumGetCString(DirectFunctionCall1(textout,PointerGetDatum(name))));
180218

181-
uuid_destroy(ns_uuid);
219+
rc=uuid_destroy(ns_uuid);
220+
if (rc!=UUID_RC_OK)
221+
pguuid_complain(rc);
182222

183223
returnresult;
184224
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp