File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -8061,15 +8061,18 @@ ValueExprNode* LiteralNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
80618061 constant->litDesc .setTextType (sym->intlsym_ttype );
80628062 }
80638063
8064+ // dsqlDesc needs dsc_length to be adjusted to maximum length for given charset,
8065+ // while litDesc must reflect the real literal length to prevent buffer overrun.
8066+
8067+ constant->dsqlDesc = constant->litDesc ;
8068+
80648069 USHORT adjust = 0 ;
80658070
80668071 if (constant->litDesc .dsc_dtype == dtype_varying)
80678072 adjust = sizeof (USHORT);
80688073 else if (constant->litDesc .dsc_dtype == dtype_cstring)
80698074 adjust = 1 ;
80708075
8071- constant->litDesc .dsc_length -= adjust;
8072-
80738076 CharSet* charSet = INTL_charset_lookup (tdbb, INTL_GET_CHARSET (&constant->litDesc ));
80748077
80758078 if (!charSet->wellFormed (dsqlStr->getString ().length (), constant->litDesc .dsc_address , NULL ))
@@ -8091,11 +8094,9 @@ ValueExprNode* LiteralNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
80918094 METD_get_charset_name (dsqlScratch->getTransaction (), constant->litDesc .getCharSet ()).toQuotedString ());
80928095 }
80938096 else
8094- constant->litDesc .dsc_length = charLength * charSet->maxBytesPerChar ();
8097+ constant->dsqlDesc .dsc_length = charLength * charSet->maxBytesPerChar () + adjust ;
80958098 }
80968099
8097- constant->litDesc .dsc_length += adjust;
8098-
80998100 return constant;
81008101}
81018102
You can’t perform that action at this time.
0 commit comments