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 12:42:43 |
Message-ID: | 20060609124243.GA17547@soptik.pzkagis.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-odbc |
Fri, Jun 09, 2006 at 02:13:23PM +0200, Ludek Finstrle napsal(a):
> > > > 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.
>
> I change the snprintf_addlen to snprintf_len as you mentioned.
I take a look at all snprintf in psqlodbc an I find one more place
where it's problematic.
If we accept snprintf_add I change one call to it.
Additional patch attached, comments are welcome
Luf
Attachment | Content-Type | Size |
---|---|---|
psqlodbc_snprintf_next.diff | text/plain | 1.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | JGuillaume 'IoGuiX' de Rorthais | 2006-06-09 12:53:17 | Re: Access97/odbcUnicode/pgsql : unable to map text field |
Previous Message | Ludek Finstrle | 2006-06-09 12:14:54 | Re: Patch for snprintf problem (bug #1000650) 3-rd try |