openbsd-ports/textproc/xxdiff/patches/patch-src_buffer_cpp

33 lines
1017 B
Plaintext

$OpenBSD: patch-src_buffer_cpp,v 1.2 2001/05/25 17:02:03 lebel Exp $
fixes multiple strcpy/strncpy/sprintf uses that could lead
to buffer overruns.
--- src/buffer.cpp.orig Thu May 24 00:40:20 2001
+++ src/buffer.cpp Thu May 24 14:33:11 2001
@@ -398,13 +398,13 @@ uint XxBuffer::computeLineNumbersWidth(
{
QFontMetrics fm( font );
char lnFormat[32];
- sprintf( lnFormat, "%%%dd", getNbDigits() );
+ snprintf( lnFormat, sizeof(lnFormat), "%%%dd", getNbDigits() );
uint longest = 0;
int nbLines = getNbLines();
char buffer[12];
for ( int ii = 1; ii <= nbLines; ++ii ) {
- sprintf( buffer, lnFormat, ii );
+ snprintf( buffer, sizeof(buffer), lnFormat, ii );
QString str( buffer );
QRect rect = fm.boundingRect( str, str.length() );
@@ -504,7 +504,7 @@ const char* XxBuffer::renderLineNumber(
const char* format
)
{
- sprintf( _lnBuffer, format, lineNumber );
+ snprintf( _lnBuffer, sizeof(_lnBuffer), format, lineNumber );
return _lnBuffer;
}