From owner-cvs-src@FreeBSD.ORG Wed Oct 17 11:41:44 2007 Return-Path: Delivered-To: cvs-src@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 15C8116A418; Wed, 17 Oct 2007 11:41:44 +0000 (UTC) (envelope-from jmallett@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 05E9313C459; Wed, 17 Oct 2007 11:41:44 +0000 (UTC) (envelope-from jmallett@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l9HBfh6X062760; Wed, 17 Oct 2007 11:41:43 GMT (envelope-from jmallett@repoman.freebsd.org) Received: (from jmallett@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l9HBfhjs062759; Wed, 17 Oct 2007 11:41:43 GMT (envelope-from jmallett) Message-Id: <200710171141.l9HBfhjs062759@repoman.freebsd.org> From: Juli Mallett Date: Wed, 17 Oct 2007 11:41:40 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Cc: Subject: cvs commit: src/usr.bin/fmt fmt.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Oct 2007 11:41:44 -0000 jmallett 2007-10-17 11:41:40 UTC FreeBSD src repository Modified files: usr.bin/fmt fmt.c Log: Prevent strange crashes in fmt with absurd goal lengths introduced by the support for wide characters. If the sizeof (wchar_t) times max_length would yield a value beyond representation in a size_t, exit with a usage error up front, rather than strange errors down the line from trying to malloc (well, realloc) with a size of 0. This is perhaps not the optimal behaviour - a clamp may be more appropriate as we clamp the value of max_length now anyway, but this is at least better than segfaulting or worse. On systems which are friendly to malloc with a value of 0 the results could end up being strange corruption of the output. Revision Changes Path 1.23 +2 -0 src/usr.bin/fmt/fmt.c