fix a bug when modify the parameter audit_data_format, if length is more than MAX_LENGTH, the errorcode is not the expected one.

This commit is contained in:
Luan-233
2023-07-28 16:42:01 +08:00
parent cfb3ff8f72
commit eada31bc13

View File

@ -8580,6 +8580,11 @@ static void replace_config_value(char** optlines, char* name, char* value, confi
rc = snprintf_s(newline, MAX_PARAM_LEN, MAX_PARAM_LEN - 1, "%s = %s\n", name, value);
break;
case PGC_STRING:
if (strlen(name) + strlen(value) + 6 >= MAX_PARAM_LEN) {
pfree(newline);
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("too long for GUC parameter.")));
}
rc = snprintf_s(newline, MAX_PARAM_LEN, MAX_PARAM_LEN - 1, "%s = '%s'\n", name, value);
break;
}