Package: jamnntpd
Version: 1.3-1+b2
Severity: important
Tags: patch upstream
-- Package-specific info:
Dear Maintainer,
jamnntpd 1.3 bundles an old jamlib whose jam.h guards its typedefs
with #ifndef linux:
#ifndef linux
typedef unsigned short ushort; /* must be 16 bits wide */
typedef unsigned long ulong; /* must be 32 bits wide */
#endif
On Linux, sys/types.h (included transitively) already defines
ulong as unsigned long — which is 64 bits wide on LP64
platforms (arm64, amd64, ppc64el, s390x, riscv64...). The guard
therefore skips the 32-bit typedef, and every JAM structure that
uses ulong silently doubles in size.
Consequences (observed on arm64, Debian trixie):
* sizeof(s_JamIndex) becomes 16 instead of 8
* JAM_GetMBSize() computes filesize / sizeof(s_JamIndex),
reporting exactly HALF the real message count
* every NNTP GROUP response shows 50% of the messages in every
area; STAT/ARTICLE/BODY for the missing half return
"423 No such article number in this group"
Reproducer:
$ python3 -c "
import socket
s = socket.create_connection(('127.0.0.1', 5000), timeout=10)
s.recv(4096)
s.sendall(b'AUTHINFO USER <user>\r\n'); s.recv(4096)
s.sendall(b'AUTHINFO PASS <pass>\r\n'); s.recv(4096)
s.sendall(b'GROUP some.area\r\n')
print(s.recv(4096).decode()) # '211 <N/2> ...' instead of '211 <N> ...'
"
$ stat -c '%s' /var/spool/fido/msgbase/some.area.jdx # = N * 8
The bug is invisible on 32-bit platforms, which likely explains
why it has gone unnoticed since the bundled jamlib was introduced.
Notably, the crashmail 1.7 package (same jamlib lineage) has
already migrated its jam.h to plain uint32_t fields — jamnntpd
just needs the same treatment.
-- Patch:
Replacing ulong with uint32_t throughout the bundled jamlib
(and makechs.c) fixes the issue. A typedef cannot simply be
redefined (typedef uint32_t ulong conflicts with sys/types.h),
so a mechanical rename is the robust fix. Full patch attached;
essentially:
-#ifndef linux
typedef unsigned short ushort; /* must be 16 bits wide */
-typedef unsigned long ulong; /* must be 32 bits wide */
-#endif
+/* all JAM fields use uint32_t directly */
After rebuilding on arm64, all NNTP group counters doubled to
their correct values (verified on a live system with ~890 JAM
areas, e.g. 3701 -> 7403 messages in one echo).
-- System Info:
Debian GNU/Linux trixie, arm64 (aarch64)
gcc (Debian 14.2.0-19) 14.2.0
jamnntpd 1.3-1+b2
Best regards,
Domini Montessori