1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Several File.list() calls missed check for null return value. Fixed

This commit is contained in:
Federico Fissore
2015-05-20 16:32:27 +02:00
parent 0b4a4fb0b5
commit 026210564d
5 changed files with 28 additions and 13 deletions

View File

@ -2604,12 +2604,15 @@ public class Base {
File targetDir) throws IOException {
targetDir.mkdirs();
String files[] = sourceDir.list();
for (int i = 0; i < files.length; i++) {
if (files == null) {
throw new IOException("Unable to list files from " + sourceDir);
}
for (String file : files) {
// Ignore dot files (.DS_Store), dot folders (.svn) while copying
if (files[i].charAt(0) == '.') continue;
if (file.charAt(0) == '.') continue;
//if (files[i].equals(".") || files[i].equals("..")) continue;
File source = new File(sourceDir, files[i]);
File target = new File(targetDir, files[i]);
File source = new File(sourceDir, file);
File target = new File(targetDir, file);
if (source.isDirectory()) {
//target.mkdirs();
copyDir(source, target);

View File

@ -150,6 +150,9 @@ public class Archiver implements Tool {
public void buildZip(File dir, String sofar,
ZipOutputStream zos) throws IOException {
String files[] = dir.list();
if (files == null) {
throw new IOException("Unable to list files from " + dir);
}
for (int i = 0; i < files.length; i++) {
if (files[i].equals(".") ||
files[i].equals("..")) continue;