Skip to content

Commit c13ef1a

Browse files
committed
My patch to fe-connect.c introduced a new bug which is triggered only, if
Kerberos is being used (attempt to free static memory). The error was caused by a confusing doublespeak of fe_getauthname(): Returns a pointer to static memory, if you authenticate via Kerberos, a pointer to dynamic memory otherwise. Submitted by: Erich Stamberger <eberger@gewi.kfunigraz.ac.at>
1 parent 1a675fe commit c13ef1a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/interfaces/libpq/fe-auth.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.2 1996/07/23 03:35:11 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.3 1996/07/27 02:27:55 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -500,14 +500,15 @@ fe_getauthsvc(char* PQerrormsg)
500500
}
501501

502502
/*
503-
* fe_getauthname -- returns a pointer to static space containing whatever
503+
* fe_getauthname -- returns a pointer to dynamic space containing whatever
504504
* name the user has authenticated to the system
505505
* if there is an error, return the error message in PQerrormsg
506506
*/
507507
char*
508508
fe_getauthname(char* PQerrormsg)
509509
{
510510
char *name = (char *) NULL;
511+
char *authn = (char *) NULL;
511512
MsgType authsvc;
512513

513514
authsvc = fe_getauthsvc(PQerrormsg);
@@ -525,11 +526,7 @@ fe_getauthname(char* PQerrormsg)
525526
case STARTUP_MSG:
526527
{
527528
struct passwd *pw = getpwuid(geteuid());
528-
if (pw &&
529-
pw->pw_name &&
530-
(name = (char *) malloc(strlen(pw->pw_name) + 1))) {
531-
(void) strcpy(name, pw->pw_name);
532-
}
529+
if (pw) name = pw->pw_name;
533530
}
534531
break;
535532
default:
@@ -538,7 +535,10 @@ fe_getauthname(char* PQerrormsg)
538535
authsvc);
539536
break;
540537
}
541-
return(name);
538+
539+
if(name && (authn = (char *) malloc(strlen(name) + 1)))
540+
(void) strcpy(authn, name);
541+
return(authn);
542542
}
543543

544544

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