From 6387ca917fbfa6bb5173bb42dab7ea17bb156dce Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 3 May 2014 21:22:21 +0000 Subject: [PATCH] Fixed buffer overflow with parts with very long descriptions. --- common/piece.cpp | 3 ++- qt/lc_config.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/common/piece.cpp b/common/piece.cpp index 11244a63..2dcde353 100644 --- a/common/piece.cpp +++ b/common/piece.cpp @@ -308,7 +308,8 @@ void lcPiece::CreateName(const lcArray& Pieces) max = i; } - sprintf (m_strName, "%s #%.2d", mPieceInfo->m_strDescription, max+1); + snprintf(m_strName, sizeof(m_strName), "%s #%.2d", mPieceInfo->m_strDescription, max+1); + m_strName[sizeof(m_strName) - 1] = 0; } void lcPiece::InsertTime(unsigned short start, unsigned short time) diff --git a/qt/lc_config.h b/qt/lc_config.h index f9522ce5..1f2ddecb 100644 --- a/qt/lc_config.h +++ b/qt/lc_config.h @@ -28,6 +28,7 @@ typedef quintptr lcuintptr; #endif #ifdef Q_OS_WIN +#define snprintf _snprintf #define isnan _isnan #define strcasecmp stricmp #define strncasecmp strnicmp