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 */
346345static void
347- pg_GSS_error_int (char * mprefix , char * msg , int msglen ,
346+ pg_GSS_error_int (PQExpBuffer str , const char * mprefix ,
348347 OM_uint32 stat , int type )
349348{
350- int curlen = 0 ;
351349 OM_uint32 lmaj_s ,
352350 lmin_s ;
353351 gss_buffer_desc lmsg ;
@@ -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 */
375366static void
376- pg_GSS_error (char * mprefix , PGconn * conn ,
367+ pg_GSS_error (const char * mprefix , PGconn * conn ,
377368 OM_uint32 maj_stat , OM_uint32 min_stat )
378369{
379- int mlen ;
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