Ticket #5504: libs_libmythdb-dont-pass-null-to-write.patch

File libs_libmythdb-dont-pass-null-to-write.patch, 1.6 KB (added by Erik Hovland <erik@…>, 16 years ago)

short ckt zero length buffer writes so null is not passed to write()

  • mythtv/libs/libmythdb/msocketdevice_unix.cpp

    The system call write() should never be given a null
    
    From: Erik Hovland <erik@hovland.org>
    
    pointer to store data in, even if there is a write length
    of zero.
    ---
    
     mythtv/libs/libmythdb/msocketdevice_unix.cpp |   10 ++++++++--
     1 files changed, 8 insertions(+), 2 deletions(-)
    
    diff --git a/mythtv/libs/libmythdb/msocketdevice_unix.cpp b/mythtv/libs/libmythdb/msocketdevice_unix.cpp
    index ee895ae..1c1f7eb 100644
    a b qint64 MSocketDevice::readData( char *data, qint64 maxlen ) 
    825825*/
    826826qint64 MSocketDevice::writeData( const char *data, qint64 len )
    827827{
    828     if ( data == 0 && len != 0 ) {
     828    if ( len == 0 )
     829        return 0;
     830
     831    if ( data == 0 ) {
    829832#if defined(QT_CHECK_NULL) || defined(QSOCKETDEVICE_DEBUG)
    830833        qWarning( "MSocketDevice::writeBlock: Null pointer error" );
    831834#endif
    qint64 MSocketDevice::writeData( const char *data, qint64 len ) 
    913916qint64 MSocketDevice::writeBlock( const char * data, quint64 len,
    914917                               const QHostAddress & host, quint16 port )
    915918{
     919    if ( len == 0 )
     920        return 0;
     921
    916922    if ( t != Datagram ) {
    917923#if defined(QT_CHECK_STATE) || defined(QSOCKETDEVICE_DEBUG)
    918924        qWarning( "MSocketDevice::sendBlock: Not datagram" );
    qint64 MSocketDevice::writeBlock( const char * data, quint64 len, 
    920926        return -1; // for now - later we can do t/tcp
    921927    }
    922928
    923     if ( data == 0 && len != 0 ) {
     929    if ( data == 0 ) {
    924930#if defined(QT_CHECK_NULL) || defined(QSOCKETDEVICE_DEBUG)
    925931        qWarning( "MSocketDevice::sendBlock: Null pointer error" );
    926932#endif