X-Recipient: archive-cygwin AT delorie DOT 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 DOT 6020409 AT redhat DOT com> <2BF01EB27B56CC478AD6E5A0A28931F203DD4166 AT A1DAL1SWPES19MB DOT ams DOT acs-inc DOT net> Date: Tue, 24 Jan 2012 10:16:38 +0100 Message-ID: Subject: Re: isprint core dump From: Csaba Raduly To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=ISO-8859-1 Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT 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