LIST COUNT and '-Q' or '-nqd'

Urs Janßen urs at tin.org
Sun Jan 3 19:05:58 CET 2016


In <mailman.418.1451822555.23414.tin-dev at tin.org>, Dennis Preiser wrote:
> It seems to be that a code path for this specific combination is
> missing.

the following patch should fix this and another issue (nntp cmd. arg
too long):

=== modified file 'include/nntplib.h'
--- include/nntplib.h	2015-11-22 00:46:22 +0000
+++ include/nntplib.h	2016-01-03 16:10:24 +0000
@@ -148,7 +148,11 @@
  * RFC 977 defines this; don't change it.
  */
 #define NNTP_STRLEN		512
-
+/*
+ * RFC 3977 3.1
+ */
+#define NNTP_GRPLEN		497
+  
 /*
  * OVERVIEW.FMT field types
  */

=== modified file 'src/active.c'
--- src/active.c	2015-11-22 00:46:22 +0000
+++ src/active.c	2016-01-03 17:10:01 +0000
@@ -316,7 +316,7 @@
 	int window = 0;
 	t_artnum count = T_ARTNUM_CONST(-1), min = T_ARTNUM_CONST(1), max = T_ARTNUM_CONST(0);
 	t_artnum processed = T_ARTNUM_CONST(0);
-	static char ngname[NNTP_STRLEN]; /* RFC 3977 3.1 limits group names to 497 octets */
+	static char ngname[NNTP_GRPLEN + 1]; /* RFC 3977 3.1 limits group names to 497 octets */
 	struct t_group *grpptr;
 #ifdef NNTP_ABLE
 	t_bool need_auth = FALSE;
@@ -726,6 +726,7 @@
 	FILE *fp;
 	int newgrps = 0;
 	t_bool do_group_cmds = !nntp_caps.list_counts;
+	t_bool did_list_cmd = FALSE;
 
 	/*
 	 * Ignore -n if no .newsrc can be found or .newsrc is empty
@@ -746,11 +747,13 @@
 	/* Read an active file if it is allowed */
 	if (list_active) {
 #ifdef NNTP_ABLE
-		if (read_news_via_nntp && nntp_caps.type == CAPABILITIES && nntp_caps.list_counts)
+		if (read_news_via_nntp && nntp_caps.list_counts)
 			read_active_counts();
 		else
 #endif /* NNTP_ABLE */
 			read_active_file();
+
+		did_list_cmd = TRUE;
 	}
 
 	/* Read .newsrc and check each group */
@@ -758,15 +761,10 @@
 #ifdef NNTP_ABLE
 #	ifndef DISABLE_PIPELINING
 		/*
-		 * use "LIST ACTIVE grp" (or even LIST ACTIVE grp,...) if we have
-		 * less than PIPELINE_LIMIT groups and we use -n but not -Q
-		 *
-		 * TODO: test me. do we want this overhead? add a DISABLE_PIPELINING
-		 *       code-path? we don't have list_active set but we use some
-		 *       sort of LIST ACTIVE -> our documentation is a bit incorrect
-		 *       now.
+		 * always prefer LIST COUNTS, otherwise use
+		 * LIST ACIVE (-l) or GROUP (-n) or both (-ln)
 		 */
-		if (read_news_via_nntp && !list_active && ((nntp_caps.type == CAPABILITIES && nntp_caps.list_active) || nntp_caps.type != CAPABILITIES) && (show_description || check_for_new_newsgroups)) {
+		if (read_news_via_nntp && (list_active || nntp_caps.list_counts) && !did_list_cmd) {
 			char buff[NNTP_STRLEN];
 			char *ptr, *q;
 			char moderated[PATH_LEN];
@@ -789,7 +787,7 @@
 						*q = '\0';
 						if (nntp_caps.type == CAPABILITIES && (nntp_caps.list_active || nntp_caps.list_counts)) {
 							/* LIST ACTIVE or LIST COUNTS takes wildmats */
-							if (*buff && ((strlen(buff) + strlen(ptr)) < (NNTP_STRLEN - 1))) { /* append group name */
+							if (*buff && ((strlen(buff) + strlen(ptr)) < (NNTP_GRPLEN - 1))) { /* append group name */
 								snprintf(buff + strlen(buff), sizeof(buff) - strlen(buff), ",%s", ptr);
 							} else {
 								if (*buff) {

=== modified file 'src/mail.c'
--- src/mail.c	2015-11-22 00:46:22 +0000
+++ src/mail.c	2016-01-03 16:11:02 +0000
@@ -315,7 +315,7 @@
 						if (group->type == GROUP_TYPE_NEWS) {
 							if (nntp_caps.type == CAPABILITIES && nntp_caps.list_newsgroups) {
 								if (*buff) {
-									if (strlen(buff) + strlen(active[i].name) + 1 < NNTP_STRLEN) {
+									if (strlen(buff) + strlen(active[i].name) + 1 < NNTP_GRPLEN) {
 										snprintf(buff + strlen(buff), sizeof(buff) - strlen(buff), ",%s", active[i].name);
 										continue;
 									} else {





More information about the tin-dev mailing list