Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4ab8fcb

Browse files
committed
StrNCpy -> strlcpy (not complete)
1 parent1a1474b commit4ab8fcb

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
charsalt[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
returnrc;

‎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
* AUTHORDATEMAJOR 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
elseif (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
elseif (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
elseif (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
charfull_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,

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.77 2007/02/01 19:10:28 momjian Exp $
7+
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.78 2007/02/10 14:58:55 petere Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -416,7 +416,7 @@ test_postmaster_connection(void)
416416
/* advance past whitespace/quoting */
417417
while (isspace((unsignedchar)*p)||*p=='\''||*p=='"')
418418
p++;
419-
StrNCpy(portstr,p,Min(strcspn(p,"\"'"WHITESPACE)+1,
419+
strlcpy(portstr,p,Min(strcspn(p,"\"'"WHITESPACE)+1,
420420
sizeof(portstr)));
421421
/* keep looking, maybe there is another -p */
422422
}
@@ -449,7 +449,7 @@ test_postmaster_connection(void)
449449
p++;
450450
while (isspace((unsignedchar)*p))
451451
p++;
452-
StrNCpy(portstr,p,Min(strcspn(p,"#"WHITESPACE)+1,
452+
strlcpy(portstr,p,Min(strcspn(p,"#"WHITESPACE)+1,
453453
sizeof(portstr)));
454454
/* keep looking, maybe there is another */
455455
}
@@ -458,7 +458,7 @@ test_postmaster_connection(void)
458458

459459
/* environment */
460460
if (!*portstr&&getenv("PGPORT")!=NULL)
461-
StrNCpy(portstr,getenv("PGPORT"),sizeof(portstr));
461+
strlcpy(portstr,getenv("PGPORT"),sizeof(portstr));
462462

463463
/* default */
464464
if (!*portstr)
@@ -594,7 +594,7 @@ do_start(void)
594594
charfull_path[MAXPGPATH];
595595

596596
if (find_my_exec(argv0,full_path)<0)
597-
StrNCpy(full_path,progname,MAXPGPATH);
597+
strlcpy(full_path,progname,sizeof(full_path));
598598

599599
if (ret==-1)
600600
write_stderr(_("The program \"postgres\" is needed by %s "

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.89 2007/01/25 03:30:43 momjian Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.90 2007/02/10 14:58:55 petere Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -150,7 +150,7 @@ main(int argc, char *argv[])
150150
charfull_path[MAXPGPATH];
151151

152152
if (find_my_exec(argv[0],full_path)<0)
153-
StrNCpy(full_path,progname,MAXPGPATH);
153+
strlcpy(full_path,progname,sizeof(full_path));
154154

155155
if (ret==-1)
156156
fprintf(stderr,

‎src/bin/pg_resetxlog/pg_resetxlog.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
2424
* Portions Copyright (c) 1994, Regents of the University of California
2525
*
26-
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.56 2007/02/01 19:10:29 momjian Exp $
26+
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.57 2007/02/10 14:58:55 petere Exp $
2727
*
2828
*-------------------------------------------------------------------------
2929
*/
@@ -498,14 +498,14 @@ GuessControlValues(void)
498498
fprintf(stderr,_("%s: invalid LC_COLLATE setting\n"),progname);
499499
exit(1);
500500
}
501-
StrNCpy(ControlFile.lc_collate,localeptr,LOCALE_NAME_BUFLEN);
501+
strlcpy(ControlFile.lc_collate,localeptr,sizeof(ControlFile.lc_collate));
502502
localeptr=setlocale(LC_CTYPE,"");
503503
if (!localeptr)
504504
{
505505
fprintf(stderr,_("%s: invalid LC_CTYPE setting\n"),progname);
506506
exit(1);
507507
}
508-
StrNCpy(ControlFile.lc_ctype,localeptr,LOCALE_NAME_BUFLEN);
508+
strlcpy(ControlFile.lc_ctype,localeptr,sizeof(ControlFile.lc_ctype));
509509

510510
/*
511511
* XXX eventually, should try to grovel through old XLOG to develop more

‎src/interfaces/libpq/fe-auth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.122 2007/01/05 22:20:00 momjian Exp $
13+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.123 2007/02/10 14:58:55 petere Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -418,7 +418,7 @@ pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq)
418418
{
419419
charsalt[3];
420420

421-
StrNCpy(salt,conn->cryptSalt,3);
421+
strlcpy(salt,conn->cryptSalt,sizeof(salt));
422422
crypt_pwd=crypt(password,salt);
423423
break;
424424
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp