* darcy@druid.net
* http://www.druid.net/darcy/
*
- * $PostgreSQL: pgsql/contrib/chkpass/chkpass.c,v 1.17 2006/07/14 05:28:27 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/chkpass/chkpass.c,v 1.18 2007/02/07 00:52:35 petere Exp $
* best viewed with tabs set to 4
*/
if (*str == ':')
{
result = (chkpass *) palloc(sizeof(chkpass));
- strncpy(result->password, str + 1, 13);
- result->password[13] = 0;
+ strlcpy(result->password, str + 1, 13 + 1);
PG_RETURN_POINTER(result);
}
if (a2->vl_len < 12)
sz = a2->vl_len - 4;
- strncpy(str, a2->vl_dat, sz);
- str[sz] = 0;
+ strlcpy(str, a2->vl_dat, sz + 1);
PG_RETURN_BOOL(strcmp(a1->password, crypt(str, a1->password)) == 0);
}
if (a2->vl_len < 12)
sz = a2->vl_len - 4;
- strncpy(str, a2->vl_dat, sz);
- str[sz] = 0;
+ strlcpy(str, a2->vl_dat, sz + 1);
PG_RETURN_BOOL(strcmp(a1->password, crypt(str, a1->password)) != 0);
}
* Darko Prenosil <Darko.Prenosil@finteh.hr>
* Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
*
- * $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.61 2007/01/05 22:19:17 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.62 2007/02/07 00:52:35 petere Exp $
* Copyright (c) 2001-2007, PostgreSQL Global Development Group
* ALL RIGHTS RESERVED;
*
errmsg("duplicate connection name")));
hentry->rconn = rconn;
- strncpy(hentry->name, name, NAMEDATALEN - 1);
+ strlcpy(hentry->name, name, sizeof(hentry->name));
}
static void
*
*
* 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
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
{
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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);
* 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 $
*
*--------------------------------------------------------------------
*/
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]);
}
*
* 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 $
*/
/*----------------------------------------------------------------------
/* 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;
}
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;
}
/*
* 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
{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];
}
* 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 $
*
*-------------------------------------------------------------------------
*/
{
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);