mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-30 20:51:13 +02:00
Check DCH_MAX_ITEM_SIZ limits with <=, not <.
We reserve space for the full amount, not one less. The affected checks deal with localized month and day names. Today's DCH_MAX_ITEM_SIZ value would suffice for a 60-byte day name, while the longest known is the 49-byte mn_CN.utf-8 word for "Saturday." Thus, the upshot of this change is merely to avoid misdirecting future readers of the code; users are not expected to see errors either way.
This commit is contained in:
parent
a7a4adcf8d
commit
237795a7b4
@ -2543,7 +2543,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
|
|||||||
{
|
{
|
||||||
char *str = str_toupper_z(localized_full_months[tm->tm_mon - 1], collid);
|
char *str = str_toupper_z(localized_full_months[tm->tm_mon - 1], collid);
|
||||||
|
|
||||||
if (strlen(str) < (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
if (strlen(str) <= (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
||||||
strcpy(s, str);
|
strcpy(s, str);
|
||||||
else
|
else
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -2563,7 +2563,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
|
|||||||
{
|
{
|
||||||
char *str = str_initcap_z(localized_full_months[tm->tm_mon - 1], collid);
|
char *str = str_initcap_z(localized_full_months[tm->tm_mon - 1], collid);
|
||||||
|
|
||||||
if (strlen(str) < (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
if (strlen(str) <= (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
||||||
strcpy(s, str);
|
strcpy(s, str);
|
||||||
else
|
else
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -2583,7 +2583,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
|
|||||||
{
|
{
|
||||||
char *str = str_tolower_z(localized_full_months[tm->tm_mon - 1], collid);
|
char *str = str_tolower_z(localized_full_months[tm->tm_mon - 1], collid);
|
||||||
|
|
||||||
if (strlen(str) < (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
if (strlen(str) <= (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
||||||
strcpy(s, str);
|
strcpy(s, str);
|
||||||
else
|
else
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -2603,7 +2603,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
|
|||||||
{
|
{
|
||||||
char *str = str_toupper_z(localized_abbrev_months[tm->tm_mon - 1], collid);
|
char *str = str_toupper_z(localized_abbrev_months[tm->tm_mon - 1], collid);
|
||||||
|
|
||||||
if (strlen(str) < (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
if (strlen(str) <= (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
||||||
strcpy(s, str);
|
strcpy(s, str);
|
||||||
else
|
else
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -2622,7 +2622,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
|
|||||||
{
|
{
|
||||||
char *str = str_initcap_z(localized_abbrev_months[tm->tm_mon - 1], collid);
|
char *str = str_initcap_z(localized_abbrev_months[tm->tm_mon - 1], collid);
|
||||||
|
|
||||||
if (strlen(str) < (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
if (strlen(str) <= (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
||||||
strcpy(s, str);
|
strcpy(s, str);
|
||||||
else
|
else
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -2641,7 +2641,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
|
|||||||
{
|
{
|
||||||
char *str = str_tolower_z(localized_abbrev_months[tm->tm_mon - 1], collid);
|
char *str = str_tolower_z(localized_abbrev_months[tm->tm_mon - 1], collid);
|
||||||
|
|
||||||
if (strlen(str) < (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
if (strlen(str) <= (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
||||||
strcpy(s, str);
|
strcpy(s, str);
|
||||||
else
|
else
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -2664,7 +2664,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
|
|||||||
{
|
{
|
||||||
char *str = str_toupper_z(localized_full_days[tm->tm_wday], collid);
|
char *str = str_toupper_z(localized_full_days[tm->tm_wday], collid);
|
||||||
|
|
||||||
if (strlen(str) < (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
if (strlen(str) <= (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
||||||
strcpy(s, str);
|
strcpy(s, str);
|
||||||
else
|
else
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -2682,7 +2682,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
|
|||||||
{
|
{
|
||||||
char *str = str_initcap_z(localized_full_days[tm->tm_wday], collid);
|
char *str = str_initcap_z(localized_full_days[tm->tm_wday], collid);
|
||||||
|
|
||||||
if (strlen(str) < (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
if (strlen(str) <= (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
||||||
strcpy(s, str);
|
strcpy(s, str);
|
||||||
else
|
else
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -2700,7 +2700,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
|
|||||||
{
|
{
|
||||||
char *str = str_tolower_z(localized_full_days[tm->tm_wday], collid);
|
char *str = str_tolower_z(localized_full_days[tm->tm_wday], collid);
|
||||||
|
|
||||||
if (strlen(str) < (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
if (strlen(str) <= (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
||||||
strcpy(s, str);
|
strcpy(s, str);
|
||||||
else
|
else
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -2718,7 +2718,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
|
|||||||
{
|
{
|
||||||
char *str = str_toupper_z(localized_abbrev_days[tm->tm_wday], collid);
|
char *str = str_toupper_z(localized_abbrev_days[tm->tm_wday], collid);
|
||||||
|
|
||||||
if (strlen(str) < (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
if (strlen(str) <= (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
||||||
strcpy(s, str);
|
strcpy(s, str);
|
||||||
else
|
else
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -2735,7 +2735,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
|
|||||||
{
|
{
|
||||||
char *str = str_initcap_z(localized_abbrev_days[tm->tm_wday], collid);
|
char *str = str_initcap_z(localized_abbrev_days[tm->tm_wday], collid);
|
||||||
|
|
||||||
if (strlen(str) < (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
if (strlen(str) <= (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
||||||
strcpy(s, str);
|
strcpy(s, str);
|
||||||
else
|
else
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
@ -2752,7 +2752,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
|
|||||||
{
|
{
|
||||||
char *str = str_tolower_z(localized_abbrev_days[tm->tm_wday], collid);
|
char *str = str_tolower_z(localized_abbrev_days[tm->tm_wday], collid);
|
||||||
|
|
||||||
if (strlen(str) < (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
if (strlen(str) <= (n->key->len + TM_SUFFIX_LEN) * DCH_MAX_ITEM_SIZ)
|
||||||
strcpy(s, str);
|
strcpy(s, str);
|
||||||
else
|
else
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
|
Loading…
Reference in New Issue
Block a user