Date: Tue, 10 Jun 2014 06:04:25 +0000 (UTC) From: Rui Paulo <rpaulo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267317 - head/usr.bin/dtc Message-ID: <201406100604.s5A64PSD088035@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rpaulo Date: Tue Jun 10 06:04:25 2014 New Revision: 267317 URL: http://svnweb.freebsd.org/changeset/base/267317 Log: dtc: don't crash if the argument is a directory. Modified: head/usr.bin/dtc/fdt.cc Modified: head/usr.bin/dtc/fdt.cc ============================================================================== --- head/usr.bin/dtc/fdt.cc Tue Jun 10 05:58:46 2014 (r267316) +++ head/usr.bin/dtc/fdt.cc Tue Jun 10 06:04:25 2014 (r267317) @@ -42,6 +42,8 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> #include "dtb.hh" namespace dtc @@ -1078,6 +1080,13 @@ device_tree::buffer_for_file(const char fprintf(stderr, "Unable to open file %s\n", path); return 0; } + struct stat st; + if (fstat(source, &st) == 0 && S_ISDIR(st.st_mode)) + { + fprintf(stderr, "File %s is a directory\n", path); + close(source); + return 0; + } input_buffer *b = new mmap_input_buffer(source); // Keep the buffer that owns the memory around for the lifetime // of this FDT. Ones simply referring to it may have shorter
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406100604.s5A64PSD088035>