X-Original-To: pgsql-odbc-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 6DCA89FA621 for ; Fri, 9 Jun 2006 09:11:29 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 20856-10 for ; Fri, 9 Jun 2006 09:11:20 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp.pzkagis.cz (gis6.netbox.cz [83.240.30.214]) by postgresql.org (Postfix) with ESMTP id 536249FA61D for ; Fri, 9 Jun 2006 09:11:19 -0300 (ADT) Received: from soptik.pzkagis.cz (localhost.localdomain [127.0.0.1]) by smtp.pzkagis.cz (8.13.1/8.13.1) with ESMTP id k59CDP1W017310; Fri, 9 Jun 2006 14:13:25 +0200 Received: (from luf@localhost) by soptik.pzkagis.cz (8.13.1/8.13.1/Submit) id k59CDNTt017309; Fri, 9 Jun 2006 14:13:24 +0200 Date: Fri, 9 Jun 2006 14:13:23 +0200 From: Ludek Finstrle To: Hiroshi Inoue Cc: pgsql-odbc@postgresql.org Subject: Re: Patch for snprintf problem (bug #1000650) 3-rd try Message-ID: <20060609121323.GA17258@soptik.pzkagis.cz> References: <20060607173910.GA28221@soptik.pzkagis.cz> <4488B6EA.9050107@tpf.co.jp> <20060609081637.GA8153@soptik.pzkagis.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060609081637.GA8153@soptik.pzkagis.cz> User-Agent: Mutt/1.4.1i X-Virus-Scanned: ClamAV 0.88.2/1523/Fri Jun 9 09:10:10 2006 on smtp.pzkagis.cz X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/50 X-Sequence-Number: 7798 > > > 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. Third try of patch attached. Comments are welcome Luf