Re: build error [was: Re: lftp 4.5.0]

"Alexander V. Lukyanov" <[email protected]>
Newsgroups gmane.network.lftp.user
Message-ID <[email protected]>
On Fri, May 23, 2014 at 02:36:59PM +0200, Noël Köthe wrote:
> Hello Alexander,
>
> Am Freitag, den 23.05.2014, 11:16 +0400 schrieb Alexander V. Lukyanov:
>
> > lftp-4.5.0 has been released. Changes:
>
> I'm trying to build this new version but run into this error:
>
> Torrent.cc:2869:69: error: format not a string literal and no format arguments [-Werror=format-security]
>          LogError(4,dc=_("peer closed connection (before handshake)"));

Nice catch. In fact there was also a logic error which caused %s to stay in
the disconnect cause.

Here is a patch to fix it.

--
   Alexander.

_______________________________________________
lftp mailing list
[email protected]
http://univ.uniyar.ac.ru/mailman/listinfo/lftp
diff (text/plain, 1.7 KB)
diff --git a/src/Torrent.cc b/src/Torrent.cc
index 4eb1e4d..1ce4ea6 100644
--- a/src/Torrent.cc
+++ b/src/Torrent.cc
@@ -2861,14 +2861,17 @@ int TorrentPeer::Do()
       if(s==UNPACK_NO_DATA_YET)
 	 return m;
       if(s!=UNPACK_SUCCESS) {
-	 const char *dc=0;
 	 if(s==UNPACK_PREMATURE_EOF) {
-	    if(recv_buf->Size()>0)
-	       LogError(2,dc=_("peer unexpectedly closed connection after %s"),recv_buf->Dump());
-	    else
-	       LogError(4,dc=_("peer closed connection (before handshake)"));
+	    if(recv_buf->Size()>0) {
+	       LogError(2,_("peer unexpectedly closed connection after %s"),recv_buf->Dump());
+	       Disconnect(_("peer unexpectedly closed connection"));
+	    } else {
+	       LogError(4,_("peer closed connection (before handshake)"));
+	       Disconnect(_("peer closed connection (before handshake)"));
+	    }
+	 } else {
+	    Disconnect(_("invalid peer response format"));
 	 }
-	 Disconnect(dc);
 	 return MOVED;
       }
       if(!parent->HasMetadata() && !LTEPExtensionEnabled()) {
@@ -2976,12 +2979,13 @@ int TorrentPeer::Do()
       return m;
    if(st!=UNPACK_SUCCESS)
    {
-      const char *dc=0;
-      if(st==UNPACK_PREMATURE_EOF)
-	 LogError(2,dc=_("peer unexpectedly closed connection after %s"),recv_buf->Dump());
-      else
-	 LogError(2,dc=_("invalid peer response format"));
-      Disconnect(dc);
+      if(st==UNPACK_PREMATURE_EOF) {
+	 LogError(2,_("peer unexpectedly closed connection after %s"),recv_buf->Dump());
+	 Disconnect(_("peer unexpectedly closed connection"));
+      } else {
+	 LogError(2,_("invalid peer response format"));
+	 Disconnect(_("invalid peer response format"));
+      }
       return MOVED;
    }
    reply->DropData(recv_buf);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.