[From nobody Thu Nov 12 10:29:07 2026
Received: (at submit) by bugs.debian.org; 15 Oct 2026 07:11:23 +0000
X-Spam-Checker-Version: SpamAssassin 4.0.1-bugs.debian.org_2005_01_02
 (2024-03-25) on buxtehude.debian.org
X-Spam-Level: 
X-Spam-Status: No, score=-7.9 required=4.0 tests=BAYES_00,FOURLA,NO_RELAYS,
 XMAILER_REPORTBUG autolearn=ham autolearn_force=no
 version=4.0.1-bugs.debian.org_2005_01_02
X-Spam-Bayes: score:0.0000 Tokens: new, 35; hammy, 150; neutral, 127; spammy,
 0. spammytokens: hammytokens:0.000-+--XDebbugsCc,
 0.000-+--X-Debbugs-Cc, 0.000-+--H*Ad:N*Bug, 0.000-+--HTo:N*Debian,
 0.000-+--forky
Return-path: &lt;seb128@ubuntu.com&gt;
Received: via submission by buxtehude.debian.org with esmtp (Exim 4.96)
 (envelope-from &lt;seb128@ubuntu.com&gt;) id 1xHFcY-009wXw-39
 for submit@bugs.debian.org; Thu, 15 Oct 2026 07:11:23 +0000
Content-Type: multipart/mixed; boundary=&quot;===============6033513397474231739==&quot;
MIME-Version: 1.0
From: Sebastien Bacher &lt;seb128@ubuntu.com&gt;
To: Debian Bug Tracking System &lt;submit@bugs.debian.org&gt;
Subject: pftools: Fix heap buffer overflow in PrintTSV
Message-ID: &lt;179204827679.522949.12902112343319077289.reportbug@seb128-ThinkPad-T16&gt;
X-Mailer: reportbug 13.2.0+ubuntu1
Date: Thu, 15 Oct 2026 09:11:16 +0200
Delivered-To: submit@bugs.debian.org

This is a multi-part MIME message sent by reportbug.


--===============6033513397474231739==
Content-Type: text/plain; charset=&quot;us-ascii&quot;
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Source: pftools
Version: 3.2.12-3ubuntu1
Severity: normal
Tags: patch
X-Debbugs-Cc: seb128@ubuntu.com
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu stonking ubuntu-patch

Hi,

pfsearchV3 has a one-byte heap overflow in PrintTSV() (src/C/utils/output.c):

  char * ac  = calloc(strlen(prf-&gt;AC_Number),sizeof(char));
  strcpy(ac,prf-&gt;AC_Number);

The buffer has no room for the ending NUL (the other output functions
in the same file use 1+strlen()). It's visible with -D_FORTIFY_SOURCE=3,
which Ubuntu uses by default: the TSV output test aborts with
&quot;*** buffer overflow detected ***&quot; and the build fails.

The attached patch fixes it; with it all 6 tests pass. It's still present
in upstream master (v3.2.13).

Ubuntu bug: https://bugs.launchpad.net/bugs/2170856

Thanks,
Sebastien Bacher


-- System Information:
Debian Release: forky/sid
  APT prefers resolute-updates
  APT policy: (500, 'resolute-updates'), (500, 'resolute-security'), (500, 'resolute'), (100, 'resolute-backports')
Architecture: amd64 (x86_64)

Kernel: Linux 7.0.0-38-generic (SMP w/16 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_WARN, TAINT_OOT_MODULE
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

--===============6033513397474231739==
Content-Type: text/plain; charset=&quot;us-ascii&quot;
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=&quot;fix-tsv-ac-overflow.patch&quot;

Description: Fix heap buffer overflow in PrintTSV
 The buffer for the accession number is allocated without room for the
 ending NUL, so the following strcpy() writes one byte past the end.
 With _FORTIFY_SOURCE=3 this aborts pfsearchV3 -o 7 (TSV output).
 The other output functions already allocate 1+strlen().
Author: Sebastien Bacher &lt;seb128@ubuntu.com&gt;
Bug-Ubuntu: https://bugs.launchpad.net/bugs/2170856
Forwarded: https://github.com/sib-swiss/pftools3/pull/33
Last-Update: 2026-10-15
Index: pftools-3.2.12/src/C/utils/output.c
===================================================================
--- pftools-3.2.12.orig/src/C/utils/output.c
+++ pftools-3.2.12/src/C/utils/output.c
@@ -64,7 +64,7 @@ void PrintTSV(const struct Profile * con
     while ( *cptr != ';' &amp;&amp; *cptr != '\0') ++cptr;
     *cptr = '\0';
 
-    char * ac  = calloc(strlen(prf-&gt;AC_Number),sizeof(char));
+    char * ac  = calloc(1+strlen(prf-&gt;AC_Number),sizeof(char));
     strcpy(ac,prf-&gt;AC_Number);
     cptr = ac;
     while ( *cptr != ';' &amp;&amp; *cptr != '\0' ) ++cptr;

--===============6033513397474231739==--
]