From: | Ludek Finstrle <luf(at)pzkagis(dot)cz> |
---|---|
To: | Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp> |
Cc: | pgsql-odbc(at)postgresql(dot)org |
Subject: | Re: Patch for snprintf problem (bug #1000650) |
Date: | 2006-06-09 08:16:37 |
Message-ID: | 20060609081637.GA8153@soptik.pzkagis.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-odbc |
> > 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;
> }
>
> ...
I'm not sure. There are a lot of strcat, my_strcat, schema_strcat calls
between snprintf. There is only one place where snprintf could be called
after another snprintf.
BTW it's something what snprintf_addlen is doing. Or am I miss something?
I do the patch with minimal changes in mind. In my opinion strcat
may be faster in joining more char *.
Regards,
Luf
From | Date | Subject | |
---|---|---|---|
Next Message | Ludek Finstrle | 2006-06-09 08:20:29 | Re: Connect to remote database via psql? |
Previous Message | Hiroshi Inoue | 2006-06-08 23:53:38 | Re: CVS and open cursor |