Re: Patch for snprintf problem (bug #1000650)
| От | Hiroshi Inoue |
|---|---|
| Тема | Re: Patch for snprintf problem (bug #1000650) |
| Дата | |
| Msg-id | 4488B6EA.9050107@tpf.co.jp обсуждение исходный текст |
| Ответ на | Patch for snprintf problem (bug #1000650) (Ludek Finstrle <luf@pzkagis.cz>) |
| Ответы |
Re: Patch for snprintf problem (bug #1000650)
|
| Список | pgsql-odbc |
Ludek Finstrle wrote:
> Hello,
>
> I found the problem in snprintf on linux (maybe another unix) boxes
> in info.c (CVS HEAD). The problematic part is something like:
>
> buf = "text";
> snprintf(buf,size,"%s append",buf);
>
> buf = "text append" on Windows (MS VC compiler)
> buf = " append" on linux (gcc compiler)
>
> I solve it this way (main idea):
> snprintf(buf + strlen(buf), " append");
Hmm bad news.
If so, it may be better to use the sequence like the following for example.
char *query_ptr;
size_t bufsize_res;
int slen;
/* Initialize */
query_ptr = columns_query;
bufsize_res = sizeof(columns_query);
if (..)
{
if ((slen = snprintf(query_ptr, bufsize_res, .., )) <= 0)
{
.. error_handling ..
}
query_ptr += slen;
bufsize_res -= slen;
}
...
regards,
Hiroshi Inoue
В списке pgsql-odbc по дате отправления: