svn commit: r267317 - head/usr.bin/dtc

Rui Paulo rpaulo at FreeBSD.org
Tue Jun 10 06:04:26 UTC 2014


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


More information about the svn-src-head mailing list