[pan: 1/7] This fixes xovers with huge article numbers being mishandled




commit e5f25f09cdb9c7a2b610e6fc1af25a7e685af6ae
Author: Thomas Tanner <thosrtanner googlemail com>
Date:   Sun Jun 19 18:55:32 2022 +0100

    This fixes xovers with huge article numbers being mishandled

 pan/tasks/nntp.cc | 41 +++++++++++++++++++++++------------------
 1 file changed, 23 insertions(+), 18 deletions(-)
---
diff --git a/pan/tasks/nntp.cc b/pan/tasks/nntp.cc
index 597bf08..394d946 100644
--- a/pan/tasks/nntp.cc
+++ b/pan/tasks/nntp.cc
@@ -17,6 +17,8 @@
  *
  */
 
+#include "nntp.h"
+
 #include <config.h>
 #include <cassert>
 #include <cstdarg>
@@ -27,9 +29,8 @@
 #include <pan/general/debug.h>
 #include <pan/general/log.h>
 #include <pan/general/messages.h>
-#include "nntp.h"
 
-using namespace pan;
+namespace pan {
 
 namespace
 {
@@ -208,22 +209,24 @@ NNTP :: on_socket_response (Socket * sock UNUSED, const StringView& line_in)
            break;
 
         case GROUP_RESPONSE: {
-           // response is of form "211 qty low high group_name"
-           StringView tok, myline (line);
-           myline.pop_token (tok, ' ');
-           myline.pop_token (tok, ' ');
-           const unsigned long aqty (strtoul (tok.str, NULL, 10));
-           myline.pop_token (tok, ' ');
-           const unsigned long alo (strtoul (tok.str, NULL, 10));
-           myline.pop_token (tok, ' ');
-           const unsigned long ahi (strtoul (tok.str, NULL, 10));
-           myline.pop_token (tok, ' ');
-           const pan::Quark group (tok);
-           if (_listener)
-              _listener->on_nntp_group (this, group, aqty, alo, ahi);
-           _group = group;
-            state = CMD_DONE;
-           break;
+          // response is of form "211 qty low high group_name"
+          StringView tok;
+          StringView myline(line);
+          myline.pop_token(tok, ' ');
+          myline.pop_token(tok, ' ');
+          uint64_t const aqty{strtoull(tok.str, NULL, 10)};
+          myline.pop_token(tok, ' ');
+          uint64_t const alo{strtoull(tok.str, NULL, 10)};
+          myline.pop_token(tok, ' ');
+          uint64_t const ahi{strtoull(tok.str, NULL, 10)};
+          myline.pop_token(tok, ' ');
+          Quark const group{tok};
+          if (_listener) {
+            _listener->on_nntp_group(this, group, aqty, alo, ahi);
+          }
+          _group = group;
+          state = CMD_DONE;
+          break;
         }
 
         case SEND_ARTICLE_NOW:
@@ -608,3 +611,5 @@ NNTP :: post (const StringView  & msg,
     write_next_command ();
   }
 }
+
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]