X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-2.2 required=5.0	tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
In-Reply-To: <2BF01EB27B56CC478AD6E5A0A28931F203DD4166@A1DAL1SWPES19MB.ams.acs-inc.net>
References: <4F1DC95A.6020409@redhat.com>	<2BF01EB27B56CC478AD6E5A0A28931F203DD4166@A1DAL1SWPES19MB.ams.acs-inc.net>
Date: Tue, 24 Jan 2012 10:16:38 +0100
Message-ID: <CAEhDDbBvshw_h9EEbyOihfsNT5VFtYLMdLCnxj=VYs__bQcSyg@mail.gmail.com>
Subject: Re: isprint core dump
From: Csaba Raduly <rcsaba@gmail.com>
To: cygwin@cygwin.com
Content-Type: text/plain; charset=ISO-8859-1
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@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

On Mon, Jan 23, 2012 at 10:34 PM, Nellis, Kenneth  wrote:
> From: Eric Blake
>
>> No, but it DOES come from POSIX:
>> http://pubs.opengroup.org/onlinepubs/9699919799/functions/isprint.html
>>
>> And cygwin's behavior matches POSIX on this point; the bug is in your
>> program, not cygwin.
>
> Call me blown away by the level of support this function that
> dumps core is getting, when it could act sanely (IMHO) with a
> simple "if" statement! So much for defensive programming.

Like it or not, this is how C works. If you want defensive programming
with bounds checking and stuff, try Pascal or Java.

The man page of isprint states:
int isprint(int c);
These functions check whether c, which must have the value of an
unsigned char or EOF...

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If the argument has any other value, the behavior is undefined.

This is a contract between the library and you, the library user. You
promise to pass an argument between -1 and 255. isprint promises to
return a correct result.

You didn't keep your promise, so isprint is free to do anything it
wants including, but not limited to, opening your web browser at
http://nooooooooooooooo.com/

Csaba
-- 
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds

--
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

