Merge "Prevent buffer over-read in linker.cpp's parse_path."
This commit is contained in:
		@@ -60,7 +60,7 @@ LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 | 
					LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LOCAL_STATIC_LIBRARIES := libc_nomalloc libziparchive libutils libz liblog
 | 
					LOCAL_STATIC_LIBRARIES := libc_nomalloc libziparchive libutils libbase libz liblog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LOCAL_FORCE_STATIC_EXECUTABLE := true
 | 
					LOCAL_FORCE_STATIC_EXECUTABLE := true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,6 +57,8 @@
 | 
				
			|||||||
#include "linker_phdr.h"
 | 
					#include "linker_phdr.h"
 | 
				
			||||||
#include "linker_relocs.h"
 | 
					#include "linker_relocs.h"
 | 
				
			||||||
#include "linker_reloc_iterators.h"
 | 
					#include "linker_reloc_iterators.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "base/strings.h"
 | 
				
			||||||
#include "ziparchive/zip_archive.h"
 | 
					#include "ziparchive/zip_archive.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern void __libc_init_AT_SECURE(KernelArgumentBlock&);
 | 
					extern void __libc_init_AT_SECURE(KernelArgumentBlock&);
 | 
				
			||||||
@@ -308,25 +310,9 @@ static void soinfo_free(soinfo* si) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void parse_path(const char* path, const char* delimiters,
 | 
					static void parse_path(const char* path, const char* delimiters,
 | 
				
			||||||
                       std::vector<std::string>* paths) {
 | 
					                       std::vector<std::string>* paths) {
 | 
				
			||||||
  if (path == nullptr) {
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  paths->clear();
 | 
					  paths->clear();
 | 
				
			||||||
 | 
					  if (path != nullptr) {
 | 
				
			||||||
  for (const char *p = path; ; ++p) {
 | 
					    *paths = android::base::Split(path, delimiters);
 | 
				
			||||||
    size_t len = strcspn(p, delimiters);
 | 
					 | 
				
			||||||
    // skip empty tokens
 | 
					 | 
				
			||||||
    if (len == 0) {
 | 
					 | 
				
			||||||
      continue;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    paths->push_back(std::string(p, len));
 | 
					 | 
				
			||||||
    p += len;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (*p == '\0') {
 | 
					 | 
				
			||||||
      break;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user