🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #72617

Re: Bug in slrn POST command?

#72617
From: Lars Kellogg-Stedman
Date: Thu, 10 Nov 2005 04:33
80 lines
4050 bytes
>> Well, Lars. A whole lot of people use slrn and have been doing
> so for a long time.

Hi, Alan.  My name's Lars.  I'm a little over thirty years old. I'm 
married, but we don't have any kids yet.  We do have two cats, both 
going on seven years.  I've never met you before, and I'm afraid I don't 
know what inspired the condescension and vitriol in your post.  There 
are probably more constructive ways to respond to bug reports! 

I am one of those people who's been using slrn happily for a long time 
-- probably eight years or so.  That doesn't mean that it's bug free!

For the rest of you, yes, it does look like a bug in slrn.  Fortunately, 
most news servers are reasonably lax w/r/t to the RFC; I imagine they 
strip trailing whitespace on commands, which would obviously take care 
of this problem.  Cyrus IMAP's NNTP server appears to be strict in this 
regard.

Slrn's problem is in src/nntplib.c, in _nntp_num_or_msgid_cmd().  
Arguably, the following section of code:

     {  
        if (msgid == NULL) msgid = "";
        return nntp_server_vcmd (s, "%s %s", cmd, msgid);
     }

Should probably be rewritten as:

     {  
        if (msgid == NULL)
            return nntp_server_cmd (s, cmd);
        else
            return nntp_server_vcmd (s, "%s %s", cmd, msgid);
     }

For commands with a null msgid, this would send the command only, rather 
than appending a space.  It wouldn't cause any new problems, and it 
would make slrn work with strict NNTP servers.

Just for kicks, I've written an LD_PRELOAD library that corrects slrn's 
behavior without requiring one to rebuild from source.  If you build the 
following as a shared library and LD_PRELOAD it, it will rewrite the 
erroneous "POST " command:

---[start code]---
#include <unistd.h>

#define __USE_GNU 1
#include <dlfcn.h>

ssize_t (*real_write)(int, const void *, size_t) = NULL;

ssize_t write(int fd, const void *buf, size_t count) {
        if (!real_write)
                real_write = (ssize_t (*) (int, const void*, size_t))
                        dlsym(RTLD_NEXT, "write");

        if (count >= 5 && memcmp(buf, "POST ", 5) == 0) {
                int res = real_write(fd, "POST\r\n", 6);
                if (res == -1) return -1;
                else return count;
        }

        return real_write(fd, buf, count);
}
---[end code]---

To build:

  gcc -c -fPIC -o fixslrn.o fixslrn.c
  ld -shared -o fixslrn.so fixslrn.o -ldl

To run:

  LD_PRELOAD=`pwd`/fixslrn.so slrn ...

(This all builds and runs under FC3.  Your mileage may vary anywhere 
else.)

-- Lars
Technical Details
Message-ID: <larsks-4AF904.23334109112005@news.isp.giganews.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!local01.nntp.dca.giganews.com!nntp.rcn.net!news.rcn.net.POSTED!not-for-mail
References: <larsks-ED6EA6.08383909112005@news.isp.giganews.com> <slrndn4vpg.19f.i3x9mdw@b29x3m.invalid>

Show Full Headers
Complete Article Headers
Message-ID: <larsks-4AF904.23334109112005@news.isp.giganews.com>
Subject: Re: Bug in slrn POST command?
Date: Wed, 09 Nov 2005 23:33:41 -0500
From: Lars Kellogg-Stedman <larsks@hotmail.com>
References: <larsks-ED6EA6.08383909112005@news.isp.giganews.com> <slrndn4vpg.19f.i3x9mdw@b29x3m.invalid>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!local01.nntp.dca.giganews.com!nntp.rcn.net!news.rcn.net.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 09 Nov 2005 22:33:35 -0600
Newsgroups: news.software.readers,news.software.nntp
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
User-Agent: MT-NewsWatcher/3.4 (PPC Mac OS X)
Lines: 80
NNTP-Posting-Host: 209.6.203.41
X-Trace: sv3-w7rPKyLBo7aVEm3hr7jW5pwFiF3pYJlA1/2RJ9XDubCav5jwqvvMmRv+N3kyQNzTWJzzHO1k8PM77Fo!eQYbahlhuZuPd59f3mViwCLLB6Gwv5MSrto+IyRVnxpkeTHu5FTr2YeeiFGc3/C4nAEu9u8RD+8P!MFbVobSv8r6fSw==
X-Complaints-To: abuse@rcn.net
X-DMCA-Complaints-To: abuse@rcn.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint
 properly
X-Postfilter: 1.3.32