diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/access/transam/xlog.c | 6 | ||||
-rw-r--r-- | src/backend/tsearch/spell.c | 2 | ||||
-rw-r--r-- | src/backend/utils/adt/datetime.c | 11 |
3 files changed, 10 insertions, 9 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 85a0ce90180..76c244c915f 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5844,7 +5844,7 @@ recoveryStopsAfter(XLogRecord *record) recoveryStopAfter = true; recoveryStopXid = InvalidTransactionId; (void) getRecordTimestamp(record, &recoveryStopTime); - strncpy(recoveryStopName, recordRestorePointData->rp_name, MAXFNAMELEN); + strlcpy(recoveryStopName, recordRestorePointData->rp_name, MAXFNAMELEN); ereport(LOG, (errmsg("recovery stopping at restore point \"%s\", time %s", @@ -6311,7 +6311,7 @@ StartupXLOG(void) * Save archive_cleanup_command in shared memory so that other processes * can see it. */ - strncpy(XLogCtl->archiveCleanupCommand, + strlcpy(XLogCtl->archiveCleanupCommand, archiveCleanupCommand ? archiveCleanupCommand : "", sizeof(XLogCtl->archiveCleanupCommand)); @@ -9107,7 +9107,7 @@ XLogRestorePoint(const char *rpName) xl_restore_point xlrec; xlrec.rp_time = GetCurrentTimestamp(); - strncpy(xlrec.rp_name, rpName, MAXFNAMELEN); + strlcpy(xlrec.rp_name, rpName, MAXFNAMELEN); rdata.buffer = InvalidBuffer; rdata.data = (char *) &xlrec; diff --git a/src/backend/tsearch/spell.c b/src/backend/tsearch/spell.c index 1ca64423297..1bc226d3347 100644 --- a/src/backend/tsearch/spell.c +++ b/src/backend/tsearch/spell.c @@ -255,7 +255,7 @@ NIAddSpell(IspellDict *Conf, const char *word, const char *flag) } Conf->Spell[Conf->nspell] = (SPELL *) tmpalloc(SPELLHDRSZ + strlen(word) + 1); strcpy(Conf->Spell[Conf->nspell]->word, word); - strncpy(Conf->Spell[Conf->nspell]->p.flag, flag, MAXFLAGLEN); + strlcpy(Conf->Spell[Conf->nspell]->p.flag, flag, MAXFLAGLEN); Conf->nspell++; } diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 946adfad997..0d32428e407 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -89,10 +89,10 @@ const char *const days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", * Note that this table must be strictly alphabetically ordered to allow an * O(ln(N)) search algorithm to be used. * - * The text field is NOT guaranteed to be NULL-terminated. + * The token field is NOT guaranteed to be NULL-terminated. * - * To keep this table reasonably small, we divide the lexval for TZ and DTZ - * entries by 15 (so they are on 15 minute boundaries) and truncate the text + * To keep this table reasonably small, we divide the value for TZ and DTZ + * entries by 15 (so they are on 15 minute boundaries) and truncate the token * field at TOKMAXLEN characters. * Formerly, we divided by 10 rather than 15 but there are a few time zones * which are 30 or 45 minutes away from an even hour, most are on an hour @@ -107,7 +107,7 @@ static datetkn *timezonetktbl = NULL; static int sztimezonetktbl = 0; static const datetkn datetktbl[] = { -/* text, token, lexval */ + /* token, type, value */ {EARLY, RESERV, DTK_EARLY}, /* "-infinity" reserved for "early time" */ {DA_D, ADBC, AD}, /* "ad" for years > 0 */ {"allballs", RESERV, DTK_ZULU}, /* 00:00:00 */ @@ -187,7 +187,7 @@ static const datetkn datetktbl[] = { static int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0]; static const datetkn deltatktbl[] = { - /* text, token, lexval */ + /* token, type, value */ {"@", IGNORE_DTF, 0}, /* postgres relative prefix */ {DAGO, AGO, 0}, /* "ago" indicates negative time offset */ {"c", UNITS, DTK_CENTURY}, /* "century" relative */ @@ -4215,6 +4215,7 @@ ConvertTimeZoneAbbrevs(TimeZoneAbbrevTable *tbl, tbl->numabbrevs = n; for (i = 0; i < n; i++) { + /* do NOT use strlcpy here; token field need not be null-terminated */ strncpy(newtbl[i].token, abbrevs[i].abbrev, TOKMAXLEN); newtbl[i].type = abbrevs[i].is_dst ? DTZ : TZ; TOVAL(&newtbl[i], abbrevs[i].offset / MINS_PER_HOUR); |