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>
This commit is contained in:
Marc G. Fournier 1996-07-27 02:27:55 +00:00
parent 1a675fe5b2
commit c13ef1afed
1 changed files with 8 additions and 8 deletions

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.2 1996/07/23 03:35:11 scrappy Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.3 1996/07/27 02:27:55 scrappy Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -500,7 +500,7 @@ fe_getauthsvc(char* PQerrormsg)
} }
/* /*
* fe_getauthname -- returns a pointer to static space containing whatever * fe_getauthname -- returns a pointer to dynamic space containing whatever
* name the user has authenticated to the system * name the user has authenticated to the system
* if there is an error, return the error message in PQerrormsg * if there is an error, return the error message in PQerrormsg
*/ */
@ -508,6 +508,7 @@ char*
fe_getauthname(char* PQerrormsg) fe_getauthname(char* PQerrormsg)
{ {
char *name = (char *) NULL; char *name = (char *) NULL;
char *authn = (char *) NULL;
MsgType authsvc; MsgType authsvc;
authsvc = fe_getauthsvc(PQerrormsg); authsvc = fe_getauthsvc(PQerrormsg);
@ -525,11 +526,7 @@ fe_getauthname(char* PQerrormsg)
case STARTUP_MSG: case STARTUP_MSG:
{ {
struct passwd *pw = getpwuid(geteuid()); struct passwd *pw = getpwuid(geteuid());
if (pw && if (pw) name = pw->pw_name;
pw->pw_name &&
(name = (char *) malloc(strlen(pw->pw_name) + 1))) {
(void) strcpy(name, pw->pw_name);
}
} }
break; break;
default: default:
@ -538,7 +535,10 @@ fe_getauthname(char* PQerrormsg)
authsvc); authsvc);
break; break;
} }
return(name);
if(name && (authn = (char *) malloc(strlen(name) + 1)))
(void) strcpy(authn, name);
return(authn);
} }