diff options
author | npmccallum <npmccallum@c587cffe-e639-0410-9787-d7902ae8ed56> | 2011-02-06 20:47:32 +0000 |
---|---|---|
committer | npmccallum <npmccallum@c587cffe-e639-0410-9787-d7902ae8ed56> | 2011-02-06 20:47:32 +0000 |
commit | b0f98adaa690a5abd79f7bff9e4435a67166a556 (patch) | |
tree | 46a08e8b5b603b80faf1a062529b1e3b84b139ba /libproxy | |
parent | e447f5c4c607afd776b42273b11d11a2c0d6eac2 (diff) | |
download | libproxy-b0f98adaa690a5abd79f7bff9e4435a67166a556.tar.gz |
fix invalid size read in fstat()
git-svn-id: http://libproxy.googlecode.com/svn/trunk@782 c587cffe-e639-0410-9787-d7902ae8ed56
Diffstat (limited to 'libproxy')
-rw-r--r-- | libproxy/url.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/libproxy/url.cpp b/libproxy/url.cpp index a77a18e..026cf78 100644 --- a/libproxy/url.cpp +++ b/libproxy/url.cpp @@ -36,12 +36,9 @@ #ifdef WIN32 #include <io.h> -#define pfsize(st) (st.st_size) #define close _close #define read _read #define SHUT_RDWR SD_BOTH -#else -#define pfsize(st) (st.st_blksize * st.st_blocks) #endif #include "url.hpp" @@ -394,10 +391,11 @@ char* url::get_pac() { struct stat st; if ((sock = ::open(m_path.c_str(), O_RDONLY)) < 0) return NULL; - if (!fstat(sock, &st) && pfsize(st) < PAC_MAX_SIZE) { - buffer = new char[pfsize(st)+1]; - memset(buffer, 0, pfsize(st)+1); - if (read(sock, buffer, pfsize(st)) == 0) { + + if (!fstat(sock, &st) && st.st_size < PAC_MAX_SIZE) { + buffer = new char[st.st_size+1]; + memset(buffer, 0, st.st_size+1); + if (read(sock, buffer, st.st_size) == 0) { delete[] buffer; buffer = NULL; } |