mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Replace some strncpy() by strlcpy().
This commit is contained in:
@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.76 2007/01/26 20:06:52 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.77 2007/02/07 00:52:35 petere Exp $
|
||||
*
|
||||
* Since the server static private key ($DataDir/server.key)
|
||||
* will normally be stored unencrypted so that the database
|
||||
@ -933,8 +933,8 @@ aloop:
|
||||
port->peer = SSL_get_peer_certificate(port->ssl);
|
||||
if (port->peer == NULL)
|
||||
{
|
||||
strncpy(port->peer_dn, "(anonymous)", sizeof(port->peer_dn));
|
||||
strncpy(port->peer_cn, "(anonymous)", sizeof(port->peer_cn));
|
||||
strlcpy(port->peer_dn, "(anonymous)", sizeof(port->peer_dn));
|
||||
strlcpy(port->peer_cn, "(anonymous)", sizeof(port->peer_cn));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.93 2007/01/05 22:19:43 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.94 2007/02/07 00:52:35 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -539,8 +539,7 @@ find_in_dynamic_libpath(const char *basename)
|
||||
len = piece - p;
|
||||
|
||||
piece = palloc(len + 1);
|
||||
strncpy(piece, p, len);
|
||||
piece[len] = '\0';
|
||||
strlcpy(piece, p, len + 1);
|
||||
|
||||
mangled = substitute_libpath_macro(piece);
|
||||
pfree(piece);
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.372 2007/02/01 19:10:28 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.373 2007/02/07 00:52:35 petere Exp $
|
||||
*
|
||||
*--------------------------------------------------------------------
|
||||
*/
|
||||
@ -5729,8 +5729,7 @@ ParseLongOption(const char *string, char **name, char **value)
|
||||
if (string[equal_pos] == '=')
|
||||
{
|
||||
*name = guc_malloc(FATAL, equal_pos + 1);
|
||||
strncpy(*name, string, equal_pos);
|
||||
(*name)[equal_pos] = '\0';
|
||||
strlcpy(*name, string, equal_pos + 1);
|
||||
|
||||
*value = guc_strdup(FATAL, &string[equal_pos + 1]);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.157 2007/01/05 22:19:49 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.158 2007/02/07 00:52:35 petere Exp $
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
@ -2389,9 +2389,7 @@ previous_word(int point, int skip)
|
||||
|
||||
/* make a copy */
|
||||
s = pg_malloc(end - start + 2);
|
||||
|
||||
strncpy(s, &rl_line_buffer[start], end - start + 1);
|
||||
s[end - start + 1] = '\0';
|
||||
strlcpy(s, &rl_line_buffer[start], end - start + 2);
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -2460,8 +2458,7 @@ dequote_file_name(char *text, char quote_char)
|
||||
|
||||
length = strlen(text);
|
||||
s = pg_malloc(length - 2 + 1);
|
||||
strncpy(s, text +1, length - 2);
|
||||
s[length] = '\0';
|
||||
strlcpy(s, text +1, length - 2 + 1);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* functions needed for descriptor handling
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/descriptor.c,v 1.24 2006/03/11 04:38:40 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/descriptor.c,v 1.25 2007/02/07 00:52:35 petere Exp $
|
||||
*
|
||||
* since descriptor might be either a string constant or a string var
|
||||
* we need to check for a constant if we expect a constant
|
||||
@ -323,7 +323,6 @@ descriptor_variable(const char *name, int input)
|
||||
{descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
|
||||
};
|
||||
|
||||
strncpy(descriptor_names[input], name, MAX_DESCRIPTOR_NAMELEN);
|
||||
descriptor_names[input][MAX_DESCRIPTOR_NAMELEN - 1] = 0;
|
||||
strlcpy(descriptor_names[input], name, sizeof(descriptor_names[input]));
|
||||
return (struct variable *) & varspace[input];
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.28 2007/02/01 19:10:30 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.29 2007/02/07 00:52:35 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -349,8 +349,7 @@ replace_string(char *string, char *replace, char *replacement)
|
||||
{
|
||||
char *dup = strdup(string);
|
||||
|
||||
strncpy(string, dup, ptr - string);
|
||||
string[ptr - string] = 0;
|
||||
strlcpy(string, dup, ptr - string + 1);
|
||||
strcat(string, replacement);
|
||||
strcat(string, dup + (ptr - string) + strlen(replace));
|
||||
free(dup);
|
||||
|
Reference in New Issue
Block a user