X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-0.2 required=5.0 	tests=BAYES_40,SPF_HELO_PASS,SPF_PASS
X-Spam-Check-By: sourceware.org
From: "Joseph Quinsey" <jquinsey@entrenet.com>
To: <cygwin@cygwin.com>
Subject: Cygwin 1.7.1 sprintf() with format string having 8th bit set
Date: Mon, 4 Jan 2010 01:55:01 -0500
Message-ID: <2ECEEFBE44B2488C840CA73169D69A6D@LeakyCauldron>
MIME-Version: 1.0
Content-Type: text/plain; 	charset="US-ASCII"
Content-Transfer-Encoding: 7bit
X-Declude-Sender: jquinsey@entrenet.com [199.246.24.8]
X-Declude-Spoolname: D909b045d00000e37.smd
X-Declude-RefID: str=0001.0A090206.4B41909A.0145,ss=1,fgs=0
X-Declude-Note: Scanned by Declude 4.6.35 "http://www.declude.com/x-note.htm"
X-Declude-Scan: Outgoing Score [0] at 01:54:58 on 04 Jan 2010
X-Declude-Tests: NOPOSTMASTER [1], SPFPASS [-2], FILTER-SUBJECT [2], FILTER_COUNTRY [0], ZEROHOUR [0]
X-Country-Chain: CANADA->destination
X-Declude-Code: e
X-Declude-Recipcount: 1
X-Helo: relay.thehostingservice.com
X-RevDNS: relay.thehostingservice.com
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

Hello,

In Cygwin 1,7.1, sprintf() with the format string having an 8th bit set
appears to be broken. Sample code (where I've indicated the backslashes in
the comments, in case they are stripped out by the mailer):

#include <stdio.h>

int main (void)
{
    unsigned char foo[30] = "";
    unsigned char bar[30] = "";
    unsigned char xxx[30] = "";
    sprintf (foo, "\100%s", "ABCD"); /* this is backslash one zero zero   */
    sprintf (bar, "\300%s", "ABCD"); /* this is backslash three zero zero */
    sprintf (xxx, "\300ABCD");       /* this is backslash three zero zero */
    printf ("%d %d %d %d %d\n", foo[0],foo[1],foo[2],foo[3],foo[4]);
    printf ("%d %d %d %d %d\n", bar[0],bar[1],bar[2],bar[3],bar[4]);
    printf ("%d %d %d %d %d\n", xxx[0],xxx[1],xxx[2],xxx[3],xxx[4]);
    return 0;
}

gives:

64 65 66 67 68
0 0 0 0 0
192 65 66 67 68

The second line of the output should be the same as the third.

This problem is likely to affect programs using xterm as a pseudo-terminal.
The number octal 300 (decimal 192) isn't significant here.

Regards, Joe Quinsey



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

