提交 4b188408 编写于 作者: D Daniel Gustafsson

Avoid format-overflow warning on setting headers

The new -Wformat-overflow warning in GCC7 fails to understand that
the buffer is in fact large enough, likely because it counts on the
integers possibly being negative. Move to using snprintf() instead
since that accounts for buffer size, and is really what we should
have done in the first place.  Also touch up the consumer of the
GP_CSVOPT buffer even though it's using a buffer oversized enough
to probably not cause that same warning.
上级 3f891f04
......@@ -2437,7 +2437,7 @@ external_set_env_vars_ext(extvar_t *extvar, char *uri, bool csv, char *escape, c
char *encoded_delim;
int line_delim_len;
sprintf(extvar->GP_CSVOPT,
snprintf(extvar->GP_CSVOPT, sizeof(extvar->GP_CSVOPT),
"m%dx%dq%dn%dh%d",
csv ? 1 : 0,
escape ? 255 & *escape : 0,
......
......@@ -754,7 +754,7 @@ set_httpheader(URL_CURL_FILE *fcurl, const char *name, const char *value)
elog(ERROR, "set_httpheader name/value is too long. name = %s, value=%s",
name, value);
sprintf(tmp, "%s: %s", name, value);
snprintf(tmp, sizeof(tmp), "%s: %s", name, value);
new_httpheader = curl_slist_append(fcurl->curl->x_httpheader, tmp);
if (new_httpheader == NULL)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册