Issue 294: mmap error checking is not correct.

R=Liu



git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@312 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
nealsid 2009-02-22 01:31:43 +00:00
parent 0fd2f1ae21
commit cadc8ddde9
4 changed files with 4 additions and 4 deletions

View file

@ -759,7 +759,7 @@ bool DumpSymbols::WriteSymbolFile(const std::string &obj_file,
return false;
void *obj_base = mmap(NULL, st.st_size,
PROT_READ | PROT_WRITE, MAP_PRIVATE, obj_fd, 0);
if (!obj_base)
if (obj_base == MAP_FAILED)
return false;
MmapWrapper map_wrapper(obj_base, st.st_size);
ElfW(Ehdr) *elf_header = reinterpret_cast<ElfW(Ehdr) *>(obj_base);

View file

@ -101,7 +101,7 @@ bool FileID::ElfFileIdentifier(unsigned char identifier[16]) {
}
void *base = mmap(NULL, st.st_size,
PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
if (!base) {
if (base == MAP_FAILED) {
close(fd);
return false;
}

View file

@ -650,7 +650,7 @@ bool DumpSymbols::WriteSymbolFile(const std::string &obj_file, int sym_fd) {
return false;
void *obj_base = mmap(NULL, st.st_size,
PROT_READ, MAP_PRIVATE, obj_fd, 0);
if (!obj_base)
if (obj_base == MAP_FAILED))
return false;
MmapWrapper map_wrapper(obj_base, st.st_size);
GElf_Ehdr elf_header;

View file

@ -151,7 +151,7 @@ bool FileID::ElfFileIdentifier(unsigned char identifier[16]) {
return false;
void *base = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (!base)
if (base == MAP_FAILED)
return false;
bool success = false;