Subject: pkg/23367: news/newsfetch violates NNTP spec wrt line endings
To: None <gnats-bugs@gnats.netbsd.org>
From: None <tv@pobox.com>
List: netbsd-bugs
Date: 11/04/2003 07:53:30
>Number:         23367
>Category:       pkg
>Synopsis:       news/newsfetch violates NNTP spec wrt line endings
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 04 12:56:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Todd Vierling
>Release:        NetBSD 1.6.1_STABLE
>Organization:
	DUH.ORG:  Pointing out the obvious since 1994.
>Environment:
>Description:

NNTP sez lines end in CR-LF.  newsfetch uses only LF.

>How-To-Repeat:

Use newsfetch against, say, netnews.comcast.net.  Hang at first command.

>Fix:

The change is below.  There is a diff for net.c to use "b" mode on the
stdio filehandles.  While not relevant to NetBSD et al, it is important
if pkgsrc is ever to be used on Cygwin or other different-line-ending
platform.  (Doubly important if the maintainer reappears from the void,
so that the change can be contributed back.)

I also removed USE_CONFIGURE below because it's a no-op.  There is no
configure script in newsfetch.

Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/news/newsfetch/Makefile,v
retrieving revision 1.5
diff -u -r1.5 Makefile
--- Makefile	2003/09/22 21:12:17	1.5
+++ Makefile	2003/11/04 12:50:39
@@ -2,6 +2,7 @@
 #
 
 DISTNAME=	newsfetch-1.3
+PKGREVISION=	1
 WRKSRC=		${WRKDIR}/newsfetch
 CATEGORIES=	news
 MASTER_SITES=	${MASTER_SITE_LOCAL}
@@ -9,8 +10,6 @@
 MAINTAINER=	jrf@diverge.org
 HOMEPAGE=	# doesn't work anymore - http://www.diverge.org/jrf/
 COMMENT=	Downloads newsgroup messages in mail file format
-
-USE_CONFIGURE=	yes
 
 .include "../../mk/bsd.prefs.mk"
 
Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/news/newsfetch/distinfo,v
retrieving revision 1.3
diff -u -r1.3 distinfo
--- distinfo	2003/09/22 21:12:18	1.3
+++ distinfo	2003/11/04 12:50:39
@@ -3,3 +3,5 @@
 SHA1 (newsfetch-1.3.tar.gz) = e497eecffa15d62b1cde6921734dd6e1cb9d933c
 Size (newsfetch-1.3.tar.gz) = 12159 bytes
 SHA1 (patch-aa) = 1311f2d0b7a8cdb4e07ba8b6dba491d9878e20df
+SHA1 (patch-ab) = 2d30938b62011db3afa2c0e06043b43bbb5cf0b2
+SHA1 (patch-ac) = 2241ba0950d3ee5f4c0c253cf4870cb4e070fe11
Index: patches/patch-ab
===================================================================
RCS file: patch-ab
diff -N patch-ab
--- /dev/null	Thu Jul 11 11:18:53 2002
+++ patch-ab	Tue Nov  4 12:50:39 2003
@@ -0,0 +1,76 @@
+$NetBSD$
+
+--- nntp.c.orig	Mon Nov  3 08:34:59 2003
++++ nntp.c
+@@ -51,7 +51,7 @@ void read_nntp_data() 
+ int set_reader_mode() 
+ {
+ 	read_nntp_data();
+-	fprintf(socket_fp[0], "MODE READER\n");
++	fprintf(socket_fp[0], "MODE READER\r\n");
+ 	read_nntp_data();
+ 	return (get_error(command_buf));
+ }
+@@ -191,7 +191,7 @@ int check_group() 
+ int first_art, last_art, total_art, tmp;
+ 	    
+ fprintf(stderr, "%s: ", group);
+-fprintf(socket_fp[0], "GROUP %s\n", group);
++fprintf(socket_fp[0], "GROUP %s\r\n", group);
+ read_nntp_data();
+ 	    
+ #ifdef DEBUG
+@@ -220,7 +220,7 @@ read_nntp_data();
+ 			first_article = last_art - max_article + 1;
+ 	}
+ 	    
+-	fprintf(socket_fp[0], "STAT %d\n", first_article);
++	fprintf(socket_fp[0], "STAT %d\r\n", first_article);
+ 	read_nntp_data();
+ 	    
+ 	while (!get_error_noprint(command_buf)) {
+@@ -238,7 +238,7 @@ read_nntp_data();
+ 			return (0);
+ 		}
+ 		    
+-		fprintf(socket_fp[0], "STAT %d\n", first_article);
++		fprintf(socket_fp[0], "STAT %d\r\n", first_article);
+ 		read_nntp_data();
+ 	}
+ 	    
+@@ -302,7 +302,7 @@ int check_header = 1;
+ 			fprintf(stderr, "                                    %c", 0xd);
+ 	}
+ 	    
+-	fprintf(socket_fp[0], "ARTICLE\n");
++	fprintf(socket_fp[0], "ARTICLE\r\n");
+ 	read_nntp_data();
+ 	    
+ 	if (!get_error(command_buf))
+@@ -325,7 +325,7 @@ int check_header = 1;
+ 	/*
+ 	 * Make it little fast 
+ 	 */ 
+-	fprintf(socket_fp[0], "NEXT\n");
++	fprintf(socket_fp[0], "NEXT\r\n");
+ 	article_fetching = 1;
+ 	    
+ #ifndef NO_STATUS_METER
+@@ -391,7 +391,7 @@ void get_group_list() 
+ 	char groupname[100];
+ 	    
+ 	fprintf(stderr, "\nList of NewsGroups:\n");
+-	fprintf(socket_fp[0], "LIST\n");
++	fprintf(socket_fp[0], "LIST\r\n");
+ 	read_nntp_data();
+ 	    
+ 	if (!get_error_strmsg(command_buf))
+@@ -411,7 +411,7 @@ void get_group_list() 
+ 
+ void send_quit() 
+ {
+-	fprintf(socket_fp[0], "QUIT\n");
++	fprintf(socket_fp[0], "QUIT\r\n");
+ 	read_nntp_data();
+ }
+ 
Index: patches/patch-ac
===================================================================
RCS file: patch-ac
diff -N patch-ac
--- /dev/null	Thu Jul 11 11:18:53 2002
+++ patch-ac	Tue Nov  4 12:50:39 2003
@@ -0,0 +1,19 @@
+$NetBSD$
+
+--- net.c.orig	Mon Nov  3 08:47:33 2003
++++ net.c
+@@ -104,12 +104,12 @@ int connect_server(char *server_name, in
+ void create_fd(int socketid, FILE ** sfp)
+ {
+ 
+-	if ((sfp[0] = fdopen(socketid, "w")) == NULL) {
++	if ((sfp[0] = fdopen(socketid, "wb")) == NULL) {
+ 		perror("fdopen");
+ 		close(socketid);
+ 		exit_now(1);
+ 	}
+-	if ((sfp[1] = fdopen(socketid, "r")) == NULL) {
++	if ((sfp[1] = fdopen(socketid, "rb")) == NULL) {
+ 		perror("fdopen");
+ 		close(socketid);
+ 		exit_now(1);
>Release-Note:
>Audit-Trail:
>Unformatted: