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

Commitcf82aee

Browse files
committed
Fix pg_GSS_error to use conn->errorMessage more sanely, ie, actually
work with the PQExpBuffer code instead of fighting it. This avoids anunnecessary limit on message length and fixes the latent bug thaterrorMessage.len wasn't getting set.
1 parent7c15b10 commitcf82aee

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

‎src/interfaces/libpq/fe-auth.c

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.136 2008/01/01 19:46:00 momjian Exp $
10+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.137 2008/01/31 18:58:30 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -340,14 +340,12 @@ static GSS_DLLIMP gss_OID GSS_C_NT_HOSTBASED_SERVICE = &GSS_C_NT_HOSTBASED_SERVI
340340
#endif
341341

342342
/*
343-
* Fetch all errors of a specific type that fit into a buffer
344-
* and append them.
343+
* Fetch all errors of a specific type and append to "str".
345344
*/
346345
staticvoid
347-
pg_GSS_error_int(char*mprefix,char*msg,intmsglen,
346+
pg_GSS_error_int(PQExpBufferstr,constchar*mprefix,
348347
OM_uint32stat,inttype)
349348
{
350-
intcurlen=0;
351349
OM_uint32lmaj_s,
352350
lmin_s;
353351
gss_buffer_desclmsg;
@@ -357,36 +355,25 @@ pg_GSS_error_int(char *mprefix, char *msg, int msglen,
357355
{
358356
lmaj_s=gss_display_status(&lmin_s,stat,type,
359357
GSS_C_NO_OID,&msg_ctx,&lmsg);
360-
361-
if (curlen<msglen)
362-
{
363-
snprintf(msg+curlen,msglen-curlen,"%s: %s\n",
364-
mprefix, (char*)lmsg.value);
365-
curlen+=lmsg.length;
366-
}
358+
appendPQExpBuffer(str,"%s: %s\n",mprefix, (char*)lmsg.value);
367359
gss_release_buffer(&lmin_s,&lmsg);
368360
}while (msg_ctx);
369361
}
370362

371363
/*
372-
* GSSAPI errors contains two parts. Put as much as possible of
373-
* both parts into the string.
364+
* GSSAPI errors contain two parts; put both into conn->errorMessage.
374365
*/
375366
staticvoid
376-
pg_GSS_error(char*mprefix,PGconn*conn,
367+
pg_GSS_error(constchar*mprefix,PGconn*conn,
377368
OM_uint32maj_stat,OM_uint32min_stat)
378369
{
379-
intmlen;
370+
resetPQExpBuffer(&conn->errorMessage);
380371

381372
/* Fetch major error codes */
382-
pg_GSS_error_int(mprefix,conn->errorMessage.data,
383-
conn->errorMessage.maxlen,maj_stat,GSS_C_GSS_CODE);
384-
mlen=strlen(conn->errorMessage.data);
385-
386-
/* If there is room left, try to add the minor codes as well */
387-
if (mlen<conn->errorMessage.maxlen-1)
388-
pg_GSS_error_int(mprefix,conn->errorMessage.data+mlen,
389-
conn->errorMessage.maxlen-mlen,min_stat,GSS_C_MECH_CODE);
373+
pg_GSS_error_int(&conn->errorMessage,mprefix,maj_stat,GSS_C_GSS_CODE);
374+
375+
/* Add the minor codes as well */
376+
pg_GSS_error_int(&conn->errorMessage,mprefix,min_stat,GSS_C_MECH_CODE);
390377
}
391378

392379
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp