Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 63481f0

Browse files
author
Bryan Henderson
committed
Use strncpy() and local buffers instead of snprintf(), since not everyone
has snprintf().
1 parent aa1eac7 commit 63481f0

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.16 1996/10/24 07:55:07 scrappy Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.17 1996/10/28 09:05:29 bryanh Exp $
1414
*
1515
* NOTES
1616
*
@@ -598,20 +598,23 @@ ConnStartup(Port *port, int *status,
598598
(void) strncpy(namebuf, sp.user, NAMEDATALEN);
599599
namebuf[NAMEDATALEN] = '\0';
600600
if (!namebuf[0]) {
601-
snprintf(errormsg, errormsg_len,
602-
"No Postgres username specified in startup packet.");
601+
strncpy(errormsg,
602+
"No Postgres username specified in startup packet.",
603+
errormsg_len);
603604
*status = STATUS_ERROR;
604605
} else {
605606
if (be_recvauth(msgType, port, namebuf, &sp) != STATUS_OK) {
606-
snprintf(errormsg, errormsg_len,
607-
"Failed to authenticate client as Postgres user '%s' "
608-
"using authentication scheme %d.",
609-
namebuf, msgType);
607+
char buffer[200 + sizeof(namebuf)];
608+
sprintf(buffer,
609+
"Failed to authenticate client as Postgres user '%s' "
610+
"using authentication scheme %d.",
611+
namebuf, msgType);
612+
strncpy(errormsg, buffer, errormsg_len);
610613
*status = STATUS_ERROR;
611614
} else {
612615
if (BackendStartup(&sp, port, &pid) != STATUS_OK) {
613-
snprintf(errormsg, errormsg_len,
614-
"Startup (fork) of backend failed.");
616+
strncpy(errormsg, "Startup (fork) of backend failed.",
617+
errormsg_len);
615618
*status = STATUS_ERROR;
616619
} else {
617620
errormsg[0] = '\0'; /* just for robustness */

0 commit comments

Comments
 (0)