diff options
| author | Grant Limberg <grant.limberg@zerotier.com> | 2019-06-17 15:32:27 -0700 |
|---|---|---|
| committer | Grant Limberg <grant.limberg@zerotier.com> | 2019-06-17 15:32:27 -0700 |
| commit | 21e844cd82f8b6bb03f51de996f5fb91cd3fe1f6 (patch) | |
| tree | fc76dc87732d90e81472caa2bf1a478e400cb99d /service | |
| parent | 4e2439bd127c399bc31a44611c5226ed51681728 (diff) | |
| parent | c5a07c7f20dc54d88a2f6b8b5c4462510b042325 (diff) | |
| download | infinitytier-21e844cd82f8b6bb03f51de996f5fb91cd3fe1f6.tar.gz infinitytier-21e844cd82f8b6bb03f51de996f5fb91cd3fe1f6.zip | |
Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev
Diffstat (limited to 'service')
| -rw-r--r-- | service/OneService.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/service/OneService.cpp b/service/OneService.cpp index b3d6739a..0043204c 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -2449,17 +2449,22 @@ public: return; } - if (len >= 0) { + if ((len >= 0)&&(data)) { // Check to see if we've already written this first. This reduces // redundant writes and I/O overhead on most platforms and has // little effect on others. f = fopen(p,"rb"); if (f) { - char buf[65535]; - long l = (long)fread(buf,1,sizeof(buf),f); - fclose(f); - if ((l == (long)len)&&(memcmp(data,buf,l) == 0)) - return; + char *const buf = (char *)malloc(len*4); + if (buf) { + long l = (long)fread(buf,1,(size_t)(len*4),f); + fclose(f); + if ((l == (long)len)&&(memcmp(data,buf,l) == 0)) { + free(buf); + return; + } + free(buf); + } } f = fopen(p,"wb"); |
