Skip to content

Commit 4ab8fcb

Browse files
committed
StrNCpy -> strlcpy (not complete)
1 parent 1a1474b commit 4ab8fcb

File tree

16 files changed

+58
-58
lines changed

16 files changed

+58
-58
lines changed

src/backend/bootstrap/bootstrap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.229 2007/01/22 01:35:19 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.230 2007/02/10 14:58:54 petere Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -277,7 +277,7 @@ BootstrapMain(int argc, char *argv[])
277277
SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
278278
break;
279279
case 'r':
280-
StrNCpy(OutputFileName, optarg, MAXPGPATH);
280+
strlcpy(OutputFileName, optarg, MAXPGPATH);
281281
break;
282282
case 'x':
283283
xlogop = atoi(optarg);

src/backend/libpq/crypt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
12-
* $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.72 2007/01/05 22:19:29 momjian Exp $
12+
* $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.73 2007/02/10 14:58:54 petere Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -110,7 +110,7 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass)
110110
{
111111
char salt[3];
112112

113-
StrNCpy(salt, port->cryptSalt, 3);
113+
strlcpy(salt, port->cryptSalt, sizeof(salt));
114114
crypt_pwd = crypt(shadow_pass, salt);
115115
break;
116116
}

src/backend/libpq/hba.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.159 2007/02/08 04:52:18 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.160 2007/02/10 14:58:54 petere Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -1463,7 +1463,7 @@ ident_unix(int sock, char *ident_user)
14631463
return false;
14641464
}
14651465

1466-
StrNCpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1);
1466+
strlcpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1);
14671467

14681468
return true;
14691469
#elif defined(SO_PEERCRED)
@@ -1493,7 +1493,7 @@ ident_unix(int sock, char *ident_user)
14931493
return false;
14941494
}
14951495

1496-
StrNCpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1);
1496+
strlcpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1);
14971497

14981498
return true;
14991499
#elif defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || (defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS))
@@ -1562,7 +1562,7 @@ ident_unix(int sock, char *ident_user)
15621562
return false;
15631563
}
15641564

1565-
StrNCpy(ident_user, pw->pw_name, IDENT_USERNAME_MAX + 1);
1565+
strlcpy(ident_user, pw->pw_name, IDENT_USERNAME_MAX + 1);
15661566

15671567
return true;
15681568
#else

src/backend/libpq/ip.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.39 2007/01/05 22:19:29 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/libpq/ip.c,v 1.40 2007/02/10 14:58:54 petere Exp $
1212
*
1313
* This file and the IPV6 implementation were initially provided by
1414
* Nigel Kukard <nkukard@lbsd.net>, Linux Based Systems Design
@@ -175,9 +175,9 @@ pg_getnameinfo_all(const struct sockaddr_storage * addr, int salen,
175175
if (rc != 0)
176176
{
177177
if (node)
178-
StrNCpy(node, "???", nodelen);
178+
strlcpy(node, "???", nodelen);
179179
if (service)
180-
StrNCpy(service, "???", servicelen);
180+
strlcpy(service, "???", servicelen);
181181
}
182182

183183
return rc;

src/backend/nodes/print.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.83 2007/01/20 20:45:38 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.84 2007/02/10 14:58:54 petere Exp $
1212
*
1313
* HISTORY
1414
* AUTHOR DATE MAJOR EVENT
@@ -574,28 +574,28 @@ print_plan_recursive(Plan *p, Query *parsetree, int indentLevel, char *label)
574574
RangeTblEntry *rte;
575575

576576
rte = rt_fetch(((Scan *) p)->scanrelid, parsetree->rtable);
577-
StrNCpy(extraInfo, rte->eref->aliasname, NAMEDATALEN);
577+
strlcpy(extraInfo, rte->eref->aliasname, NAMEDATALEN);
578578
}
579579
else if (IsA(p, IndexScan))
580580
{
581581
RangeTblEntry *rte;
582582

583583
rte = rt_fetch(((IndexScan *) p)->scan.scanrelid, parsetree->rtable);
584-
StrNCpy(extraInfo, rte->eref->aliasname, NAMEDATALEN);
584+
strlcpy(extraInfo, rte->eref->aliasname, NAMEDATALEN);
585585
}
586586
else if (IsA(p, FunctionScan))
587587
{
588588
RangeTblEntry *rte;
589589

590590
rte = rt_fetch(((FunctionScan *) p)->scan.scanrelid, parsetree->rtable);
591-
StrNCpy(extraInfo, rte->eref->aliasname, NAMEDATALEN);
591+
strlcpy(extraInfo, rte->eref->aliasname, NAMEDATALEN);
592592
}
593593
else if (IsA(p, ValuesScan))
594594
{
595595
RangeTblEntry *rte;
596596

597597
rte = rt_fetch(((ValuesScan *) p)->scan.scanrelid, parsetree->rtable);
598-
StrNCpy(extraInfo, rte->eref->aliasname, NAMEDATALEN);
598+
strlcpy(extraInfo, rte->eref->aliasname, NAMEDATALEN);
599599
}
600600
else
601601
extraInfo[0] = '\0';

src/backend/postmaster/pgarch.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
*
2121
* IDENTIFICATION
22-
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.28 2007/01/05 22:19:36 momjian Exp $
22+
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.29 2007/02/10 14:58:54 petere Exp $
2323
*
2424
*-------------------------------------------------------------------------
2525
*/
@@ -429,14 +429,14 @@ pgarch_archiveXlog(char *xlog)
429429
case 'p':
430430
/* %p: relative path of source file */
431431
sp++;
432-
StrNCpy(dp, pathname, endp - dp);
432+
strlcpy(dp, pathname, endp - dp);
433433
make_native_path(dp);
434434
dp += strlen(dp);
435435
break;
436436
case 'f':
437437
/* %f: filename of source file */
438438
sp++;
439-
StrNCpy(dp, xlog, endp - dp);
439+
strlcpy(dp, xlog, endp - dp);
440440
dp += strlen(dp);
441441
break;
442442
case '%':

src/backend/postmaster/postmaster.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.518 2007/02/08 15:46:04 momjian Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.519 2007/02/10 14:58:54 petere Exp $
4141
*
4242
* NOTES
4343
*
@@ -3828,7 +3828,7 @@ save_backend_variables(BackendParameters * param, Port *port,
38283828
memcpy(&param->port, port, sizeof(Port));
38293829
write_inheritable_socket(&param->portsocket, port->sock, childPid);
38303830

3831-
StrNCpy(param->DataDir, DataDir, MAXPGPATH);
3831+
strlcpy(param->DataDir, DataDir, MAXPGPATH);
38323832

38333833
memcpy(&param->ListenSocket, &ListenSocket, sizeof(ListenSocket));
38343834

@@ -3859,14 +3859,14 @@ save_backend_variables(BackendParameters * param, Port *port,
38593859

38603860
memcpy(&param->syslogPipe, &syslogPipe, sizeof(syslogPipe));
38613861

3862-
StrNCpy(param->my_exec_path, my_exec_path, MAXPGPATH);
3862+
strlcpy(param->my_exec_path, my_exec_path, MAXPGPATH);
38633863

3864-
StrNCpy(param->pkglib_path, pkglib_path, MAXPGPATH);
3864+
strlcpy(param->pkglib_path, pkglib_path, MAXPGPATH);
38653865

3866-
StrNCpy(param->ExtraOptions, ExtraOptions, MAXPGPATH);
3866+
strlcpy(param->ExtraOptions, ExtraOptions, MAXPGPATH);
38673867

3868-
StrNCpy(param->lc_collate, setlocale(LC_COLLATE, NULL), LOCALE_NAME_BUFLEN);
3869-
StrNCpy(param->lc_ctype, setlocale(LC_CTYPE, NULL), LOCALE_NAME_BUFLEN);
3868+
strlcpy(param->lc_collate, setlocale(LC_COLLATE, NULL), LOCALE_NAME_BUFLEN);
3869+
strlcpy(param->lc_ctype, setlocale(LC_CTYPE, NULL), LOCALE_NAME_BUFLEN);
38703870

38713871
return true;
38723872
}
@@ -4060,11 +4060,11 @@ restore_backend_variables(BackendParameters * param, Port *port)
40604060

40614061
memcpy(&syslogPipe, &param->syslogPipe, sizeof(syslogPipe));
40624062

4063-
StrNCpy(my_exec_path, param->my_exec_path, MAXPGPATH);
4063+
strlcpy(my_exec_path, param->my_exec_path, MAXPGPATH);
40644064

4065-
StrNCpy(pkglib_path, param->pkglib_path, MAXPGPATH);
4065+
strlcpy(pkglib_path, param->pkglib_path, MAXPGPATH);
40664066

4067-
StrNCpy(ExtraOptions, param->ExtraOptions, MAXPGPATH);
4067+
strlcpy(ExtraOptions, param->ExtraOptions, MAXPGPATH);
40684068

40694069
setlocale(LC_COLLATE, param->lc_collate);
40704070
setlocale(LC_CTYPE, param->lc_ctype);

src/backend/tcop/postgres.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.521 2007/01/05 22:19:39 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.522 2007/02/10 14:58:55 petere Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -2846,7 +2846,7 @@ PostgresMain(int argc, char *argv[], const char *username)
28462846
case 'r':
28472847
/* send output (stdout and stderr) to the given file */
28482848
if (secure)
2849-
StrNCpy(OutputFileName, optarg, MAXPGPATH);
2849+
strlcpy(OutputFileName, optarg, MAXPGPATH);
28502850
break;
28512851

28522852
case 'S':

src/backend/utils/misc/guc-file.l

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.46 2007/01/05 22:19:46 momjian Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.47 2007/02/10 14:58:55 petere Exp $
88
*/
99

1010
%{
@@ -218,7 +218,7 @@ ParseConfigFile(const char *config_file, const char *calling_file,
218218
if (!is_absolute_path(config_file))
219219
{
220220
Assert(calling_file != NULL);
221-
StrNCpy(abs_path, calling_file, MAXPGPATH);
221+
strlcpy(abs_path, calling_file, sizeof(abs_path));
222222
get_parent_directory(abs_path);
223223
join_path_components(abs_path, abs_path, config_file);
224224
canonicalize_path(abs_path);

src/bin/initdb/initdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* Portions Copyright (c) 1994, Regents of the University of California
4343
* Portions taken from FreeBSD.
4444
*
45-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.131 2007/02/01 19:10:28 momjian Exp $
45+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.132 2007/02/10 14:58:55 petere Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -2706,7 +2706,7 @@ main(int argc, char *argv[])
27062706
char full_path[MAXPGPATH];
27072707

27082708
if (find_my_exec(argv[0], full_path) < 0)
2709-
StrNCpy(full_path, progname, MAXPGPATH);
2709+
strlcpy(full_path, progname, sizeof(full_path));
27102710

27112711
if (ret == -1)
27122712
fprintf(stderr,

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