From a52b095f50701baeb8c83965aa09dad854cf1d75 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 23 Apr 2014 16:32:42 -0400 Subject: [PATCH] mosh-server: Remove unused mosh_read_line function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This function is buggy. feof(file) does not become true until after we’ve tried to read past the last character; it should instead be checking the getc return value for EOF (which is distinct from any unsigned char). Really it should just be replaced by istream &std::getline(istream &is, string &str). Fortunately, it’s unused so we can just delete it. Resolves a truncated stdio return value issue found by Coverity Scan service. Signed-off-by: Anders Kaseorg --- src/frontend/mosh-server.cc | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc index c82a350..006e786 100644 --- a/src/frontend/mosh-server.cc +++ b/src/frontend/mosh-server.cc @@ -801,19 +801,6 @@ bool device_exists( const char *ut_line ) return (0 == lstat( device_name.c_str(), &buf )); } -string mosh_read_line( FILE *file ) -{ - string ret; - while ( !feof( file ) ) { - char next = getc( file ); - if ( next == '\n' ) { - return ret; - } - ret.push_back( next ); - } - return ret; -} - void warn_unattached( const string & ignore_entry ) { #ifdef HAVE_UTMPX_H