]> TLD Linux GIT Repositories - packages/tigervnc.git/blob - tigervnc-passwd-crash-with-malloc-checks.patch
- updated to 1.10.1, updated patches from Fedora
[packages/tigervnc.git] / tigervnc-passwd-crash-with-malloc-checks.patch
1 diff --git a/common/rfb/Password.cxx b/common/rfb/Password.cxx
2 index e4a508c..f555c57 100644
3 --- a/common/rfb/Password.cxx
4 +++ b/common/rfb/Password.cxx
5 @@ -55,7 +55,7 @@ PlainPasswd::~PlainPasswd() {
6  
7  void PlainPasswd::replaceBuf(char* b) {
8    if (buf)
9 -    memset(buf, 0, strlen(buf));
10 +    memset(buf, 0, length ? length : strlen(buf));
11    CharArray::replaceBuf(b);
12  }
13  
14 diff --git a/common/rfb/util.h b/common/rfb/util.h
15 index 3100f90..764692a 100644
16 --- a/common/rfb/util.h
17 +++ b/common/rfb/util.h
18 @@ -51,16 +51,21 @@ namespace rfb {
19      CharArray() : buf(0) {}
20      CharArray(char* str) : buf(str) {} // note: assumes ownership
21      CharArray(size_t len) {
22 +      length = len;
23        buf = new char[len]();
24      }
25      ~CharArray() {
26 -      delete [] buf;
27 +      if (buf) {
28 +        delete [] buf;
29 +        buf = nullptr;
30 +      }
31      }
32      void format(const char *fmt, ...) __printf_attr(2, 3);
33      // Get the buffer pointer & clear it (i.e. caller takes ownership)
34      char* takeBuf() {char* tmp = buf; buf = 0; return tmp;}
35 -    void replaceBuf(char* b) {delete [] buf; buf = b;}
36 +    void replaceBuf(char* b) {if (buf) delete [] buf; buf = b;}
37      char* buf;
38 +    size_t length = 0;
39    private:
40      CharArray(const CharArray&);
41      CharArray& operator=(const CharArray&);