From owner-freebsd-questions@FreeBSD.ORG Mon Oct 19 05:16:07 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 1AFAB1065670 for ; Mon, 19 Oct 2009 05:16:07 +0000 (UTC) (envelope-from kline@thought.org) Received: from aristotle.thought.org (aristotle.thought.org [209.180.213.210]) by mx1.freebsd.org (Postfix) with ESMTP id ADC798FC18 for ; Mon, 19 Oct 2009 05:16:06 +0000 (UTC) Received: from thought.org (tao.thought.org [10.47.0.250]) (authenticated bits=0) by aristotle.thought.org (8.14.2/8.14.2) with ESMTP id n9J5FsVI022605; Sun, 18 Oct 2009 22:15:54 -0700 (PDT) (envelope-from kline@thought.org) From: Gary Kline Received: by thought.org (nbSMTP-1.00) for uid 1002 kline@thought.org; Sun, 18 Oct 2009 22:15:58 -0700 (PDT) Date: Sun, 18 Oct 2009 22:15:58 -0700 Cc: freebsd-questions@freebsd.org Message-ID: <20091019051557.GC9657@thought.org> References: <20091019013337.GA9522@thought.org> <72213BBF-5E05-430D-BF9A-FCD2666951C6@hiwaay.net> <20091019054344.bb4822ca.freebsd@edvax.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20091019054344.bb4822ca.freebsd@edvax.de> User-Agent: Mutt/1.4.2.3i X-Organization: Thought Unlimited. Public service Unix since 1986. X-Of_Interest: With 23 years of service to the Unix community. X-Spam-Status: No, score=-3.1 required=3.6 tests=ALL_TRUSTED,BAYES_00, MISSING_HEADERS autolearn=no version=3.2.3 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on aristotle.thought.org Subject: Re: need C help, passing char buffer[] by-value.... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Oct 2009 05:16:07 -0000 On Mon, Oct 19, 2009 at 05:43:44AM +0200, Polytropon wrote: > 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. > > right; i will add error checking once i've got things working. but i think i meant to say that i was calling by-reference, sing fgets was reading the file from a char buffer[256]; or whatever. so, given this, shouldn't i need to step past some N bytes of "buffer[]? i'll experiement and see, again, but in my one compile that worked, by-value, left in the gary > > -- > Polytropon > Magdeburg, Germany > Happy FreeBSD user since 4.0 > Andra moi ennepe, Mousa, ... > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" -- Gary Kline kline@thought.org http://www.thought.org Public Service Unix http://jottings.thought.org http://transfinite.thought.org The 7.31a release of Jottings: http://jottings.thought.org/index.php