From owner-freebsd-current Thu Mar 23 23:04:27 1995 Return-Path: current-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id XAA19330 for current-outgoing; Thu, 23 Mar 1995 23:04:27 -0800 Received: from uswat.advtech.uswest.com (firewall-user@uswat.advtech.uswest.com [130.13.16.1]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id XAA19319; Thu, 23 Mar 1995 23:04:17 -0800 Received: from lookout.ecte.uswc.uswest.com (lookout.ecte.uswc.uswest.com [151.116.109.7]) by uswat.advtech.uswest.com (8.6.11/8.6.10) with ESMTP id AAA00140; Fri, 24 Mar 1995 00:04:00 -0700 Received: (from rxscot2@localhost) by lookout.ecte.uswc.uswest.com (8.6.11/uswc-hub-V8.052394) id AAA27649; Fri, 24 Mar 1995 00:03:59 -0700 From: Rich Scott Message-Id: <199503240703.AAA27649@lookout.ecte.uswc.uswest.com> Subject: Re: ATTENTION: VERY serious hidden bug in To: ache@astral.msk.su (Andrey A. Chernov, Black Mage) Date: Fri, 24 Mar 1995 00:03:59 -0700 (MST) Cc: current@FreeBSD.org, wollman@lcs.mit.edu, dima@FreeBSD.org In-Reply-To: from "Andrey A. Chernov, Black Mage" at Mar 24, 95 07:51:26 am X-Mailer: ELM [version 2.4 PL24] Content-Type: text Content-Length: 910 Sender: current-owner@FreeBSD.org Precedence: bulk |When program uses strtok() and call gethostbyname/addr after |it, strtok() memory becomes corrupted, because private function |init_services() from gethostnamaddr.c module uses strtok() too! |AND ONLY ONE STRTOK PARSER MAY BE ACTIVE AT ONCE. Now init_services() |strtok() corrupts program strtok() internal variables. |Garrett, please, get rid of strtok() in init_services()! | |Currently this bug strongly affects at least tcp_wrapper. Chris Torek himself often suggests that people use strsep(3), which was introduced into 4.4BSD by him, instead of strtok(3), for just this reason (i.e. when you need to parse multiple strings simultaneously). strsep() also handles zero-length substrings correctly (when two delimiter chars are adjacent). It's not ANSI-standard, but it's a lot nicer than strtok(). =rich -- Rich Scott DMP/MAE USWest Technologies, Denver, CO