From c058e65f869b2da32362559787ff519747fd6b67 Mon Sep 17 00:00:00 2001 From: Ark74 Date: Sun, 17 Aug 2025 04:55:07 -0600 Subject: [PATCH] debconf: add patches to safeguard Template.pm and Cache.pm --- .../000-add_Template_undef_guard.patch | 12 ++++++++ .../001-add_DbDriver_Cache_undef_guard.patch | 12 ++++++++ helpers/make-debconf | 28 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 helpers/DATA/debconf/patch_changes/000-add_Template_undef_guard.patch create mode 100644 helpers/DATA/debconf/patch_changes/001-add_DbDriver_Cache_undef_guard.patch create mode 100644 helpers/make-debconf diff --git a/helpers/DATA/debconf/patch_changes/000-add_Template_undef_guard.patch b/helpers/DATA/debconf/patch_changes/000-add_Template_undef_guard.patch new file mode 100644 index 0000000..e30df28 --- /dev/null +++ b/helpers/DATA/debconf/patch_changes/000-add_Template_undef_guard.patch @@ -0,0 +1,12 @@ +diff --git a/Debconf/Template.pm b/Debconf/Template.pm +index 9ab4833d..c3649929 100644 +--- a/Debconf/Template.pm ++++ b/Debconf/Template.pm +@@ -140,6 +140,7 @@ Get an existing template (it may be pulled out of the database, etc). + sub get { + my Debconf::Template $this=shift; + my $template=shift; ++ return unless defined $template && length $template; + return $template{$template} if exists $template{$template}; + if ($Debconf::Db::templates->exists($template)) { + $this = fields::new($this); diff --git a/helpers/DATA/debconf/patch_changes/001-add_DbDriver_Cache_undef_guard.patch b/helpers/DATA/debconf/patch_changes/001-add_DbDriver_Cache_undef_guard.patch new file mode 100644 index 0000000..8f3b8ba --- /dev/null +++ b/helpers/DATA/debconf/patch_changes/001-add_DbDriver_Cache_undef_guard.patch @@ -0,0 +1,12 @@ +diff --git a/Debconf/DbDriver/Cache.pm b/Debconf/DbDriver/Cache.pm +index 1b0e36fb..2e80d3bb 100644 +--- a/Debconf/DbDriver/Cache.pm ++++ b/Debconf/DbDriver/Cache.pm +@@ -122,6 +122,7 @@ undef -- marked as deleted in the cache, so does not exist + sub exists { + my $this=shift; + my $item=shift; ++ return 0 unless defined $item && length $item; + + return $this->{cache}->{$item} + if exists $this->{cache}->{$item}; diff --git a/helpers/make-debconf b/helpers/make-debconf new file mode 100644 index 0000000..3bfde9c --- /dev/null +++ b/helpers/make-debconf @@ -0,0 +1,28 @@ +#!/bin/sh +# +# Copyright (C) 2025 Luis Guzmán +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +VERSION=1 + +. ./config + +apply_patch_changes + +changelog "Add undef guard for Template.pm and Cache.pm" + +package