debconf: add patches to safeguard Template.pm and Cache.pm

This commit is contained in:
Ark74 2025-08-17 04:55:07 -06:00
parent 745e43935c
commit c058e65f86
3 changed files with 52 additions and 0 deletions

View file

@ -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);

View file

@ -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};

28
helpers/make-debconf Normal file
View file

@ -0,0 +1,28 @@
#!/bin/sh
#
# Copyright (C) 2025 Luis Guzmán <ark@switnet.org>
#
# 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