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

Commit 8d320b6

Browse files
committed
Code review of strftime patch, per comments from Tom:
* Use correct buffer size MAX_L10N_DATA * Use strlcpy instead of StrNCpy
1 parent f8e5b79 commit 8d320b6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/backend/utils/adt/pg_locale.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 2002-2009, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.44 2009/01/09 13:03:55 mha Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.45 2009/01/09 14:07:00 mha Exp $
88
*
99
*-----------------------------------------------------------------------
1010
*/
@@ -476,7 +476,7 @@ strftime_win32(char *dst, size_t dstlen, const wchar_t *format, const struct tm
476476

477477
encoding = GetDatabaseEncoding();
478478

479-
len = wcsftime(wbuf, sizeof(wbuf), format, tm);
479+
len = wcsftime(wbuf, MAX_L10N_DATA, format, tm);
480480
if (len == 0)
481481
/* strftime call failed - return 0 with the contents of dst unspecified */
482482
return 0;
@@ -492,7 +492,7 @@ strftime_win32(char *dst, size_t dstlen, const wchar_t *format, const struct tm
492492
char *convstr = pg_do_encoding_conversion(dst, len, PG_UTF8, encoding);
493493
if (dst != convstr)
494494
{
495-
StrNCpy(dst, convstr, dstlen);
495+
strlcpy(dst, convstr, dstlen);
496496
len = strlen(dst);
497497
}
498498
}

0 commit comments

Comments
 (0)