Date: Mon, 5 Oct 2009 21:11:05 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r197793 - head/lib/libc/gen Message-ID: <200910052111.n95LB5mH025841@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Mon Oct 5 21:11:04 2009 New Revision: 197793 URL: http://svn.freebsd.org/changeset/base/197793 Log: fts_open() requires that the list passed as argument to contain at least one path. When the list is empty (contain only a NULL pointer), return EINVAL instead of pretending to succeed, which will cause a NULL pointer deference in a later fts_read() call. Noticed by: Christoph Mallon (via rdivacky@) MFC after: 2 weeks Modified: head/lib/libc/gen/fts.3 head/lib/libc/gen/fts.c Modified: head/lib/libc/gen/fts.3 ============================================================================== --- head/lib/libc/gen/fts.3 Mon Oct 5 20:38:36 2009 (r197792) +++ head/lib/libc/gen/fts.3 Mon Oct 5 21:11:04 2009 (r197793) @@ -28,7 +28,7 @@ .\" @(#)fts.3 8.5 (Berkeley) 4/16/94 .\" $FreeBSD$ .\" -.Dd January 26, 2008 +.Dd October 5, 2009 .Dt FTS 3 .Os .Sh NAME @@ -776,7 +776,7 @@ may fail and set as follows: .Bl -tag -width Er .It Bq Er EINVAL -The options were invalid. +The options were invalid, or the list were empty. .El .Sh SEE ALSO .Xr find 1 , Modified: head/lib/libc/gen/fts.c ============================================================================== --- head/lib/libc/gen/fts.c Mon Oct 5 20:38:36 2009 (r197792) +++ head/lib/libc/gen/fts.c Mon Oct 5 21:11:04 2009 (r197793) @@ -124,6 +124,12 @@ fts_open(argv, options, compar) return (NULL); } + /* fts_open() requires at least one path */ + if (*argv == NULL) { + errno = EINVAL; + return (NULL); + } + /* Allocate/initialize the stream. */ if ((priv = malloc(sizeof(*priv))) == NULL) return (NULL);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910052111.n95LB5mH025841>