From owner-freebsd-questions@FreeBSD.ORG Mon Oct 19 03:43:47 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 17DC6106566B for ; Mon, 19 Oct 2009 03:43:47 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) by mx1.freebsd.org (Postfix) with ESMTP id CB5F98FC17 for ; Mon, 19 Oct 2009 03:43:46 +0000 (UTC) Received: from r55.edvax.de (port-92-195-71-245.dynamic.qsc.de [92.195.71.245]) by mx01.qsc.de (Postfix) with ESMTP id E7EBE3C967 for ; Mon, 19 Oct 2009 05:43:45 +0200 (CEST) Received: from r55.edvax.de (localhost [127.0.0.1]) by r55.edvax.de (8.14.2/8.14.2) with SMTP id n9J3hiWF002569 for ; Mon, 19 Oct 2009 05:43:44 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Mon, 19 Oct 2009 05:43:44 +0200 From: Polytropon To: freebsd-questions@freebsd.org Message-Id: <20091019054344.bb4822ca.freebsd@edvax.de> In-Reply-To: <72213BBF-5E05-430D-BF9A-FCD2666951C6@hiwaay.net> References: <20091019013337.GA9522@thought.org> <72213BBF-5E05-430D-BF9A-FCD2666951C6@hiwaay.net> Organization: EDVAX X-Mailer: Sylpheed 2.4.7 (GTK+ 2.12.1; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: need C help, passing char buffer[] by-value.... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Oct 2009 03:43:47 -0000 On Sun, 18 Oct 2009 22:23:43 -0500, David Kelly wrote: > When not using a count to indicate how much data is in a char* you > should always test for null. Testing for null is not a sure fire way > to prevent buffer over runs but its better than nothing. There are means like #include ... assert(s); to make sure s is not NULL, or testing for it explicitely like if(!s) ... error handling here ... is possible. Furthermore, it is a proven way to give a length argument along with the (char *) argument, such as the "new" l-functions for strings, e. g. strlcat() and strlcpy(), do. char *skiptags(char *s, int l); You can even double-check for l begin != 0. Or you employ a test with strlen() function-internally. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...