aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2015-03-03 16:17:51 +0100
committerPierre Ossman <ossman@cendio.se>2015-03-03 16:17:51 +0100
commita7bbe9c4a3b2090240173e45bebab86e5cba3b4b (patch)
tree0bdba695d5126806843d24245ff20b3b16f3a27a /common/rfb
parent5b3c5f49b103d45ce11cd7c0319c82b95ee61e58 (diff)
downloadtigervnc-a7bbe9c4a3b2090240173e45bebab86e5cba3b4b.tar.gz
tigervnc-a7bbe9c4a3b2090240173e45bebab86e5cba3b4b.zip
Make sure Exceptions do not use unsafe format strings
Diffstat (limited to 'common/rfb')
-rw-r--r--common/rfb/CConnection.cxx9
-rw-r--r--common/rfb/Exception.h7
-rw-r--r--common/rfb/JpegCompressor.cxx4
-rw-r--r--common/rfb/JpegDecompressor.cxx4
4 files changed, 12 insertions, 12 deletions
diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx
index e0a23b5a..8ccd948b 100644
--- a/common/rfb/CConnection.cxx
+++ b/common/rfb/CConnection.cxx
@@ -97,12 +97,11 @@ void CConnection::processVersionMsg()
// The only official RFB protocol versions are currently 3.3, 3.7 and 3.8
if (cp.beforeVersion(3,3)) {
- char msg[256];
- sprintf(msg,"Server gave unsupported RFB protocol version %d.%d",
- cp.majorVersion, cp.minorVersion);
- vlog.error("%s", msg);
+ vlog.error("Server gave unsupported RFB protocol version %d.%d",
+ cp.majorVersion, cp.minorVersion);
state_ = RFBSTATE_INVALID;
- throw Exception(msg);
+ throw Exception("Server gave unsupported RFB protocol version %d.%d",
+ cp.majorVersion, cp.minorVersion);
} else if (useProtocol3_3 || cp.beforeVersion(3,7)) {
cp.setVersion(3,3);
} else if (cp.afterVersion(3,8)) {
diff --git a/common/rfb/Exception.h b/common/rfb/Exception.h
index 7c2cbcaa..5f47fcf2 100644
--- a/common/rfb/Exception.h
+++ b/common/rfb/Exception.h
@@ -24,14 +24,15 @@ namespace rfb {
typedef rdr::Exception Exception;
struct AuthFailureException : public Exception {
AuthFailureException(const char* s="Authentication failure")
- : Exception(s) {}
+ : Exception("%s", s) {}
};
struct AuthCancelledException : public rfb::Exception {
AuthCancelledException(const char* s="Authentication cancelled")
- : Exception(s) {}
+ : Exception("%s", s) {}
};
struct ConnFailedException : public Exception {
- ConnFailedException(const char* s="Connection failed") : Exception(s) {}
+ ConnFailedException(const char* s="Connection failed")
+ : Exception("%s", s) {}
};
}
#endif
diff --git a/common/rfb/JpegCompressor.cxx b/common/rfb/JpegCompressor.cxx
index c19af34e..5df0039e 100644
--- a/common/rfb/JpegCompressor.cxx
+++ b/common/rfb/JpegCompressor.cxx
@@ -123,7 +123,7 @@ JpegCompressor::JpegCompressor(int bufferLen) : MemOutStream(bufferLen)
if(setjmp(err->jmpBuffer)) {
// this will execute if libjpeg has an error
- throw rdr::Exception(err->lastError);
+ throw rdr::Exception("%s", err->lastError);
}
jpeg_create_compress(cinfo);
@@ -166,7 +166,7 @@ void JpegCompressor::compress(const rdr::U8 *buf, int stride, const Rect& r,
jpeg_abort_compress(cinfo);
if (srcBufIsTemp && srcBuf) delete[] srcBuf;
if (rowPointer) delete[] rowPointer;
- throw rdr::Exception(err->lastError);
+ throw rdr::Exception("%s", err->lastError);
}
cinfo->image_width = w;
diff --git a/common/rfb/JpegDecompressor.cxx b/common/rfb/JpegDecompressor.cxx
index ca1ad226..70a4276f 100644
--- a/common/rfb/JpegDecompressor.cxx
+++ b/common/rfb/JpegDecompressor.cxx
@@ -116,7 +116,7 @@ JpegDecompressor::JpegDecompressor(void)
if(setjmp(err->jmpBuffer)) {
// this will execute if libjpeg has an error
- throw rdr::Exception(err->lastError);
+ throw rdr::Exception("%s", err->lastError);
}
jpeg_create_decompress(dinfo);
@@ -162,7 +162,7 @@ void JpegDecompressor::decompress(const rdr::U8 *jpegBuf, int jpegBufLen,
jpeg_abort_decompress(dinfo);
if (dstBufIsTemp && dstBuf) delete[] dstBuf;
if (rowPointer) delete[] rowPointer;
- throw rdr::Exception(err->lastError);
+ throw rdr::Exception("%s", err->lastError);
}
src->pub.next_input_byte = jpegBuf;