1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

Fix seriously broken implementation of GetMagicNumber.

llvm-svn: 18422
This commit is contained in:
Reid Spencer 2004-12-02 09:09:48 +00:00
parent 5a392ee4cc
commit f16e254d8a

View File

@ -178,11 +178,13 @@ bool Path::getMagicNumber(std::string& Magic, unsigned len) const {
int fd = ::open(path.c_str(),O_RDONLY);
if (fd < 0)
return false;
if (0 != ::read(fd, buf, len))
ssize_t bytes_read = ::read(fd, buf, len);
::close(fd);
if (ssize_t(len) != bytes_read) {
Magic.clear();
return false;
close(fd);
buf[len] = '\0';
Magic = buf;
}
Magic.assign(buf,len);
return true;
}