[dpkg] 38/68: dpkg-divert: Fix short-lived memory leaks

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=1dd925c8749829db25c95e12b4b1d7c8842d391f

commit 1dd925c8749829db25c95e12b4b1d7c8842d391f
Author: Guillem Jover 
AuthorDate: Tue Aug 18 02:09:08 2020 +0200

dpkg-divert: Fix short-lived memory leaks

Warned-by: gcc ASAN
---
 src/divertcmd.c | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/divertcmd.c b/src/divertcmd.c
index e4bf3b58c..8836e67aa 100644
--- a/src/divertcmd.c
+++ b/src/divertcmd.c
@@ -133,7 +133,7 @@ opt_rename_setup(void)
 }
 
 struct file {
-   const char *name;
+   char *name;
enum {
FILE_STAT_INVALID,
FILE_STAT_VALID,
@@ -155,6 +155,12 @@ file_init(struct file *f, const char *filename)
f->stat_state = FILE_STAT_INVALID;
 }
 
+static void
+file_destroy(struct file *f)
+{
+   free(f->name);
+}
+
 static void
 file_stat(struct file *f)
 {
@@ -512,6 +518,10 @@ diversion_add(const char *const *argv)
if (opt_verbose > 0)
printf(_("Leaving '%s'\n"),
   diversion_describe(fnn_from->divert));
+
+   file_destroy(&file_from);
+   file_destroy(&file_to);
+
return 0;
}
 
@@ -558,6 +568,9 @@ diversion_add(const char *const *argv)
file_rename(&file_from, &file_to);
}
 
+   file_destroy(&file_from);
+   file_destroy(&file_to);
+
return 0;
 }
 
@@ -669,6 +682,9 @@ diversion_remove(const char *const *argv)
if (!opt_test)
divertdb_write();
 
+   file_destroy(&file_from);
+   file_destroy(&file_to);
+
return 0;
 }
 

-- 
Dpkg.Org's dpkg



[dpkg] 33/68: libdpkg: Fix short-lived memory leaks

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=38cb8160e8d44a15d1397176489915b3057fbb66

commit 38cb8160e8d44a15d1397176489915b3057fbb66
Author: Guillem Jover 
AuthorDate: Tue Aug 18 01:27:39 2020 +0200

libdpkg: Fix short-lived memory leaks

These strings are going to be auto-released on program exit.

Warned-by: gcc ASAN
---
 lib/dpkg/ehandle.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index 5bc459a0c..bfa220908 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -279,6 +279,7 @@ run_cleanups(struct error_context *econ, int flagsetin)
   if (cep->calls[i].call && cep->calls[i].mask & flagset) {
 if (setjmp(recurse_jump)) {
   run_cleanups(&recurserr, ehflag_bombout | ehflag_recursiveerror);
+  error_context_errmsg_free(&recurserr);
 } else {
   memset(&recurserr, 0, sizeof(recurserr));
   set_error_printer(&recurserr, print_cleanup_error, NULL);
@@ -428,6 +429,7 @@ run_error_handler(void)
  * abort. Hopefully the user can fix the situation (out of disk, out
  * of memory, etc). */
 print_abort_error(_("unrecoverable fatal error, aborting"), 
econtext->errmsg);
+error_context_errmsg_free(econtext);
 exit(2);
   }
 
@@ -502,5 +504,7 @@ do_internerr(const char *file, int line, const char *func, 
const char *fmt, ...)
   color_get(COLOR_ERROR), _("internal error"), color_reset(),
   econtext->errmsg);
 
+  error_context_errmsg_free(econtext);
+
   abort();
 }

-- 
Dpkg.Org's dpkg



[dpkg] 59/68: Dpkg::Changelog::Parse: Add new verbose option

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=6b15c47b743b425d3577689c26ef74ac37fcf0fa

commit 6b15c47b743b425d3577689c26ef74ac37fcf0fa
Author: Guillem Jover 
AuthorDate: Wed Aug 5 10:35:27 2020 +0200

Dpkg::Changelog::Parse: Add new verbose option

Prompted-by: #967911
---
 scripts/Dpkg/Changelog/Parse.pm | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/scripts/Dpkg/Changelog/Parse.pm b/scripts/Dpkg/Changelog/Parse.pm
index 8140e25a6..6730f6996 100644
--- a/scripts/Dpkg/Changelog/Parse.pm
+++ b/scripts/Dpkg/Changelog/Parse.pm
@@ -33,7 +33,7 @@ package Dpkg::Changelog::Parse;
 use strict;
 use warnings;
 
-our $VERSION = '2.00';
+our $VERSION = '2.01';
 our @EXPORT = qw(
 changelog_parse
 );
@@ -79,7 +79,8 @@ This function will parse a changelog. In list context, it 
returns as many
 Dpkg::Control objects as the parser did create. In scalar context, it will
 return only the first one. If the parser did not return any data, it will
 return an empty list in list context or undef on scalar context. If the
-parser failed, it will die.
+parser failed, it will die. Any parse errors will be printed as warnings
+on standard error, but this can be disabled by passing $opt{verbose} to 0.
 
 The changelog file that is parsed is F by default but it
 can be overridden with $opt{file}. The default output format is "dpkg" but
@@ -104,6 +105,7 @@ All the other keys in %opt are forwarded to the parser 
module constructor.
 sub changelog_parse {
 my (%options) = @_;
 
+$options{verbose} //= 1;
 $options{file} //= 'debian/changelog';
 $options{label} //= $options{file};
 $options{changelogformat} //= _changelog_detect_format($options{file});
@@ -129,7 +131,9 @@ sub changelog_parse {
 \$changes = Dpkg::Changelog::$format->new();
 };
 error(g_('changelog format %s is unknown: %s'), $format, $@) if $@;
-$changes->set_options(reportfile => $options{label}, range => $range);
+$changes->set_options(reportfile => $options{label},
+  verbose => $options{verbose},
+  range => $range);
 
 # Load and parse the changelog.
 $changes->load($options{file}, compression => $options{compression})
@@ -157,6 +161,10 @@ sub changelog_parse {
 
 =head1 CHANGES
 
+=head2 Version 2.01 (dpkg 1.20.6)
+
+New option: 'verbose' in changelog_parse().
+
 =head2 Version 2.00 (dpkg 1.20.0)
 
 Remove functions: changelog_parse_debian(), changelog_parse_plugin().

-- 
Dpkg.Org's dpkg



[dpkg] 40/68: dpkg-deb: Make decompression error message more descriptive

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=11a8426fb30d94bd36e0122e48fe13ee928f1c14

commit 11a8426fb30d94bd36e0122e48fe13ee928f1c14
Author: Guillem Jover 
AuthorDate: Wed Aug 26 02:41:20 2020 +0200

dpkg-deb: Make decompression error message more descriptive

Print both the ar member being decompressed, and its size, so that
truncated archives can more easily be detected after the fact.

Closes: #968442
---
 dpkg-deb/extract.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
index 605a18440..d0f6cb6c4 100644
--- a/dpkg-deb/extract.c
+++ b/dpkg-deb/extract.c
@@ -298,7 +298,9 @@ extracthalf(const char *debar, const char *dir,
 if (taroption)
   close(p2[0]);
 decompress_filter(decompressor, p1[0], p2_out,
-  _("decompressing archive member"));
+  _("decompressing archive '%s' (size=%jd) member '%s'"),
+  ar->name, (intmax_t)ar->size,
+  admininfo ? ADMINMEMBER : DATAMEMBER);
 exit(0);
   }
   close(p1[0]);

-- 
Dpkg.Org's dpkg



[dpkg] 61/68: Dpkg::Source::Package::V1: Print a message when verifying tarball signatures

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=a40c250be499ba93157c4db8cfcb35d924ccf6f8

commit a40c250be499ba93157c4db8cfcb35d924ccf6f8
Author: Guillem Jover 
AuthorDate: Fri Sep 4 19:13:57 2020 +0200

Dpkg::Source::Package::V1: Print a message when verifying tarball signatures

This action is actually important, and performing it silently means the
user will not be aware that it is happening.
---
 scripts/Dpkg/Source/Package/V1.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/Dpkg/Source/Package/V1.pm 
b/scripts/Dpkg/Source/Package/V1.pm
index ac8af8cc9..0709e491e 100644
--- a/scripts/Dpkg/Source/Package/V1.pm
+++ b/scripts/Dpkg/Source/Package/V1.pm
@@ -433,6 +433,7 @@ sub do_build {
 info(g_('building %s using existing %s'), $sourcepackage, $tarsign);
 $self->add_file($tarsign);
 
+info(g_('verifying %s using existing %s'), $tarname, $tarsign);
 $self->check_original_tarball_signature($dir, $tarsign);
 } else {
 my $key = $self->get_upstream_signing_key($dir);

-- 
Dpkg.Org's dpkg



[dpkg] 60/68: Dpkg::Changelog::Parse: Document 'label' option

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=3b9afd43dd3b6ababed84900bf36363b8e70704c

commit 3b9afd43dd3b6ababed84900bf36363b8e70704c
Author: Guillem Jover 
AuthorDate: Wed Aug 5 10:35:27 2020 +0200

Dpkg::Changelog::Parse: Document 'label' option
---
 scripts/Dpkg/Changelog/Parse.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/Dpkg/Changelog/Parse.pm b/scripts/Dpkg/Changelog/Parse.pm
index 6730f6996..bda09b4b0 100644
--- a/scripts/Dpkg/Changelog/Parse.pm
+++ b/scripts/Dpkg/Changelog/Parse.pm
@@ -83,8 +83,9 @@ parser failed, it will die. Any parse errors will be printed 
as warnings
 on standard error, but this can be disabled by passing $opt{verbose} to 0.
 
 The changelog file that is parsed is F by default but it
-can be overridden with $opt{file}. The default output format is "dpkg" but
-it can be overridden with $opt{format}.
+can be overridden with $opt{file}. The changelog name used in output messages
+can be specified with $opt{label}, otherwise it will default to $opt{file}.
+The default output format is "dpkg" but it can be overridden with $opt{format}.
 
 The parsing itself is done by a parser module (searched in the standard
 perl library directories. That module is named according to the format that

-- 
Dpkg.Org's dpkg



[dpkg] 02/68: doc: Update l10n commit documentation

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=511f7183dfc3ab82488120d0c4955dac1f9de282

commit 511f7183dfc3ab82488120d0c4955dac1f9de282
Author: Guillem Jover 
AuthorDate: Sun Nov 8 03:36:45 2020 +0100

doc: Update l10n commit documentation

Changelog: silent
---
 README.l10n | 59 +--
 1 file changed, 17 insertions(+), 42 deletions(-)

diff --git a/README.l10n b/README.l10n
index 549675f04..0b9645a63 100644
--- a/README.l10n
+++ b/README.l10n
@@ -1,63 +1,38 @@
 Translators, when adding/updating your translation files, please follow
 the following rules:
 
-* Update debian/changelog:
+* Do not update debian/changelog:
 
+  - The file will get generated out of the commit messages at release time.
   - Beware that you should NOT update any of the legacy ChangeLog.old
 files for translation updates.
 
-* Format of entries in debian/changelog:
-
-  Translation updates should go in a dedicated "[ Updated foo translations ]"
-  section:
-
-==
-dpkg (1.13.15) unstable; urgency=low
-
-  .../...
-
-  [ Updated programs translations ]
-  * Catalan (Jordi Mallach).
-  * Portuguese (Miguel Figueiredo).
-  * Swedish (Daniel Nylander).
-==
-
-  New translations should go in a dedicated section named
-  "[ New scripts translations ]":
+* Format of commit message
 
-==
-dpkg (1.13.15) unstable; urgency=low
+  Following guidelines in 
+  you should start the commit message with a summary line, followed by an
+  empty line and optional pseudo-headers.
 
-  .../...
+  The summary line should use the following format:
 
-  [ New dselect translations ]
-  * Vogon (Douglas Adams).
-==
+  «po:translation»
 
-  This file contents MUST be encoded in UTF-8, and the entries inserted
-  in language alphabetical order.
+  Where:
 
-* Format of commit message
+  -  is one of “Update” or “Add”,
+  -  should be capitalized (such as “English”),
+  -  should be one of «programs» (for lib, src/, dpkg-deb/, dpkg-split/
+and utils/), «dselect», «scripts» and «man pages» (man/).
 
-  The formats above only apply to the debian/changelog file.
-  They do not apply to the commit message. Following recommendations
-  of  you should start the
-  commit message with a summary line, followed by an empty line and a
-  a detailed/long description. For example:
+  For example:
 
 ==
-Update German translation of manual pages
+po: Update German programs translation
 
-Update to 1354t.
+Closes: #123456
+Reviewed-by: Full Name 
 ==
 
-  Note that the update should mention the file statistics as XXXtYYYfZZZu.
-
-  "XXXt" means "XXX translated strings".
-  "YYYf" means "YYY fuzzy strings strings".
-  "ZZZu" means "ZZZ untranslated strings".
-  YYY or ZZZ may be omitted if they are null.
-
 * Use of po/LINGUAS, dselect/po/LINGUAS or scripts/po/LINGUAS:
 
   When ADDING a new translation, don't forget adding the language to

-- 
Dpkg.Org's dpkg



[dpkg] 66/68: Dpkg::Source::Package: Call syserr() instead of syserror()

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=9e34f5c14ad086fa7f5e77afdaea71aefe796ffc

commit 9e34f5c14ad086fa7f5e77afdaea71aefe796ffc
Author: Guillem Jover 
AuthorDate: Mon Nov 2 09:23:36 2020 +0100

Dpkg::Source::Package: Call syserr() instead of syserror()

Ref: #849752
Reported-by: Drew Parsons 
---
 scripts/Dpkg/Source/Package.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm
index 19a49eeba..1c9bc41fc 100644
--- a/scripts/Dpkg/Source/Package.pm
+++ b/scripts/Dpkg/Source/Package.pm
@@ -544,7 +544,7 @@ sub extract {
 my $dst = File::Spec->catfile($destdir, $orig);
 if (not check_files_are_the_same($src, $dst, 1)) {
 cp($src, $dst)
-or syserror(g_('cannot copy %s to %s'), $src, $dst);
+or syserr(g_('cannot copy %s to %s'), $src, $dst);
 }
 }
 }

-- 
Dpkg.Org's dpkg



[dpkg] 23/68: debian: Improve cron file robustness on missing or empty backup files

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=25797abf7f08c7db8c380fa08338088dd5acac49

commit 25797abf7f08c7db8c380fa08338088dd5acac49
Author: Guillem Jover 
AuthorDate: Fri Sep 4 00:02:44 2020 +0200

debian: Improve cron file robustness on missing or empty backup files

Check whether the database files exist and ignore them otherwise. If
some database file has been modified, but the current file being
processed does not exist, created an empty backup so that they are
all in sync with their sequence number.

Closes: #969472
---
 debian/dpkg.cron.daily | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/debian/dpkg.cron.daily b/debian/dpkg.cron.daily
index 0a135f729..11124f7dd 100644
--- a/debian/dpkg.cron.daily
+++ b/debian/dpkg.cron.daily
@@ -9,15 +9,21 @@ if cd /var/backups ; then
   dbchanged=no
   dbfiles="arch status diversions statoverride"
   for db in $dbfiles ; do
-if ! cmp -s "dpkg.${db}.0" "$dbdir/$db"; then
+if ! [ -s "dpkg.${db}.0" ] && ! [ -s "$dbdir/$db" ]; then
+  # Special case the files not existing or being empty as being equal.
+  continue
+elif ! cmp -s "dpkg.${db}.0" "$dbdir/$db"; then
   dbchanged=yes
   break
 fi
   done
   if [ "$dbchanged" = "yes" ] ; then
 for db in $dbfiles ; do
-  [ -e "$dbdir/$db" ] || continue
-  cp -p "$dbdir/$db" "dpkg.$db"
+  if [ -e "$dbdir/$db" ]; then
+cp -p "$dbdir/$db" "dpkg.$db"
+  else
+touch "dpkg.$db"
+  fi
   savelog -c 7 "dpkg.$db" >/dev/null
 done
   fi

-- 
Dpkg.Org's dpkg



[dpkg] 03/68: Dpkg::Index: Add new item_opts option

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=41a98902abdc32eddaa454422abe96f2948f9718

commit 41a98902abdc32eddaa454422abe96f2948f9718
Author: Guillem Jover 
AuthorDate: Sun Nov 8 03:45:41 2020 +0100

Dpkg::Index: Add new item_opts option

This option makes it possible to pass options to the item constructor
in new_item() method.
---
 scripts/Dpkg/Index.pm | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/scripts/Dpkg/Index.pm b/scripts/Dpkg/Index.pm
index cfe86ba17..6dc46dad4 100644
--- a/scripts/Dpkg/Index.pm
+++ b/scripts/Dpkg/Index.pm
@@ -19,7 +19,7 @@ package Dpkg::Index;
 use strict;
 use warnings;
 
-our $VERSION = '2.00';
+our $VERSION = '2.01';
 
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
@@ -61,6 +61,7 @@ sub new {
unique_tuple_key => 1,
get_key_func => sub { return $_[0]->{Package} },
type => CTRL_UNKNOWN,
+item_opts => {},
 };
 bless $self, $class;
 $self->set_options(%opts);
@@ -77,7 +78,9 @@ The "type" option is checked first to define default values 
for other
 options. Here are the relevant options: "get_key_func" is a function
 returning a key for the item passed in parameters, "unique_tuple_key" is
 a boolean requesting whether the default key should be the unique tuple
-(default to true). The index can only contain one item with a given key.
+(default to true), "item_opts" is a hash reference that will be passed to
+the item constructor in the new_item() method.
+The index can only contain one item with a given key.
 The "get_key_func" function used depends on the type:
 
 =over
@@ -264,7 +267,7 @@ object.
 
 sub new_item {
 my $self = shift;
-return Dpkg::Control->new(type => $self->{type});
+return Dpkg::Control->new(%{$self->{item_opts}}, type => $self->{type});
 }
 
 =item $item = $index->get_by_key($key)
@@ -426,6 +429,10 @@ based on their extensions.
 
 =head1 CHANGES
 
+=head2 Version 2.01 (dpkg 1.20.6)
+
+New option: Add new "item_opts" option.
+
 =head2 Version 2.00 (dpkg 1.20.0)
 
 Change behavior: The "unique_tuple_key" option now defaults to true.

-- 
Dpkg.Org's dpkg



[dpkg] 64/68: Dpkg::Path: Fix pathname traversal check for symlinks

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=727edc4d287796a139e6f4d4f367ead995b5d919

commit 727edc4d287796a139e6f4d4f367ead995b5d919
Author: Guillem Jover 
AuthorDate: Mon Sep 28 02:44:10 2020 +0200

Dpkg::Path: Fix pathname traversal check for symlinks

If the canonicalized pathname from the symlink matches the canonicalized
root directory, then they are the same directory and there is no
directory traversal.

Closes: #971203
---
 scripts/Dpkg/Path.pm  |  1 +
 scripts/t/Dpkg_Path.t | 10 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/scripts/Dpkg/Path.pm b/scripts/Dpkg/Path.pm
index 782bc4230..22c2c55bb 100644
--- a/scripts/Dpkg/Path.pm
+++ b/scripts/Dpkg/Path.pm
@@ -226,6 +226,7 @@ sub check_directory_traversal {
 syserr(g_("pathname '%s' cannot be canonicalized"), $_);
 }
 return if $canon_pathname eq '/dev/null';
+return if $canon_pathname eq $canon_basedir;
 return if $canon_pathname =~ m{^\Q$canon_basedir/\E};
 
 error(g_("pathname '%s' points outside source root (to '%s')"),
diff --git a/scripts/t/Dpkg_Path.t b/scripts/t/Dpkg_Path.t
index bfd5b8db5..33d1f9267 100644
--- a/scripts/t/Dpkg_Path.t
+++ b/scripts/t/Dpkg_Path.t
@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 33;
+use Test::More tests => 34;
 use Test::Dpkg qw(:paths);
 
 use Cwd qw(realpath);
@@ -75,6 +75,14 @@ my %travtype = (
 fail => 0,
 gen => sub { },
 },
+same => {
+fail => 0,
+chroot => "$tmpdir/travbase-same",
+gen => sub {
+my $basedir = shift;
+symlink '../..', "$basedir/subdir/root";
+},
+},
 dev_null => {
 fail => 0,
 gen => sub {

-- 
Dpkg.Org's dpkg



[dpkg] 26/68: test: Improve dpkg-divert test to output stdout and stderr

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=7d2d5be9fb48c79d25991e5ab4da2a4f6419d241

commit 7d2d5be9fb48c79d25991e5ab4da2a4f6419d241
Author: Guillem Jover 
AuthorDate: Tue Aug 18 02:08:00 2020 +0200

test: Improve dpkg-divert test to output stdout and stderr

This makes spotting unexpected values, or output from sanitizers easier.
---
 src/t/dpkg_divert.t | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/t/dpkg_divert.t b/src/t/dpkg_divert.t
index cf118e212..b24f8856f 100644
--- a/src/t/dpkg_divert.t
+++ b/src/t/dpkg_divert.t
@@ -90,13 +90,17 @@ sub call {
   to_pipe => \$output, error_to_pipe => \$error, %opts);
 
 if ($opts{expect_failure}) {
-ok($? != 0, "@$args should fail");
+ok($? != 0, "@$args should fail: $?");
 } else  {
-ok($? == 0, "@$args should not fail");
+ok($? == 0, "@$args should not fail: $?");
 }
 
+my @output = <$output>;
+my @error = <$error>;
+note("stdout <<<@output>>>");
+note("stderr <<<@error>>>");
+
 if (defined $opts{expect_stdout}) {
-my (@output) = <$output>;
 my (@expect) = split(/^/, $opts{expect_stdout});
 if (defined $opts{expect_sorted_stdout}) {
 @output = sort @output;
@@ -105,13 +109,13 @@ sub call {
 is(join('', @output), join('', @expect), "@$args stdout");
 }
 if (defined $opts{expect_stdout_like}) {
-like(file_slurp($output), $opts{expect_stdout_like}, "@$args stdout");
+like("@output", $opts{expect_stdout_like}, "@$args stdout");
 }
 if (defined $opts{expect_stderr}) {
-is(file_slurp($error), $opts{expect_stderr}, "@$args stderr");
+is("@error", $opts{expect_stderr}, "@$args stderr");
 }
 if (defined $opts{expect_stderr_like}) {
-like(file_slurp($error), $opts{expect_stderr_like}, "@$args stderr");
+like("@error", $opts{expect_stderr_like}, "@$args stderr");
 }
 
 close($output);

-- 
Dpkg.Org's dpkg



[dpkg] 39/68: dpkg-realpath: Add new -z, --zero option

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=fd4d0448474d7d7dbea664660a24964db2ffadba

commit fd4d0448474d7d7dbea664660a24964db2ffadba
Author: Guillem Jover 
AuthorDate: Sat Aug 15 15:49:50 2020 +0200

dpkg-realpath: Add new -z, --zero option

This makes it possible to process files with newlines within, even though
not all of the dpkg suite is prepared to cope with those.

Requested-by: Johannes Schauer 
---
 man/dpkg-realpath.pod| 5 +
 scripts/dpkg-realpath.sh | 7 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/man/dpkg-realpath.pod b/man/dpkg-realpath.pod
index f48ce1279..192ed0745 100644
--- a/man/dpkg-realpath.pod
+++ b/man/dpkg-realpath.pod
@@ -33,6 +33,11 @@ B is a tool to resolve a pathname.
 
 =over
 
+=item B<-z>, B<--zero>
+
+Use a NUL byte to end output lines instead of a new line character
+(since dpkg 1.20.6).
+
 =item B<--instdir> I
 
 Set the installation directory, which refers to the directory where
diff --git a/scripts/dpkg-realpath.sh b/scripts/dpkg-realpath.sh
index 75b451ad8..2f4396f00 100755
--- a/scripts/dpkg-realpath.sh
+++ b/scripts/dpkg-realpath.sh
@@ -20,6 +20,7 @@ set -e
 
 PROGNAME=$(basename "$0")
 version="unknown"
+EOL="\n"
 
 PKGDATADIR="${DPKG_DATADIR:-scripts}"
 
@@ -41,6 +42,7 @@ show_usage()
 Usage: $PROGNAME [...] 
 
 Options:
+  -z,  --zero   end output line with NUL, not newline.
--instdir set the root directory.
--rootset the root directory.
--versionshow the version.
@@ -113,7 +115,7 @@ canonicalize() {
   done
   # We are done, print the resolved pathname, w/o $root.
   result="${result#"$root"}"
-  echo "${result:-/}"
+  printf "%s$EOL" "${result:-/}"
 }
 
 setup_colors
@@ -123,6 +125,9 @@ export DPKG_ROOT
 
 while [ $# -ne 0 ]; do
   case "$1" in
+  -z|--zero)
+EOL="\0"
+;;
   --instdir|--root)
 shift
 DPKG_ROOT=$1

-- 
Dpkg.Org's dpkg



[dpkg] 57/68: Dpkg::Exit: Fix exit handler on program termination

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=6d03bf8df86e17be013c31f5a4522d8c8fbcb823

commit 6d03bf8df86e17be013c31f5a4522d8c8fbcb823
Author: Guillem Jover 
AuthorDate: Thu Jul 23 04:29:56 2020 +0200

Dpkg::Exit: Fix exit handler on program termination

We cannot hook into the __DIE__ pseudo signal handler as then any
eval usage becomes unsafe. Instead we hook into an END code block,
and fix the run_exit_handler code to deplete the @handlers array so
that we do not execute the handlers repeatedly and to reset the
installed handlers as not needed anymore.

Closes: #966083
---
 scripts/Dpkg/Exit.pm  | 11 +--
 scripts/t/Dpkg_Exit.t | 12 +++-
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/scripts/Dpkg/Exit.pm b/scripts/Dpkg/Exit.pm
index 70a29b1a6..07f122fab 100644
--- a/scripts/Dpkg/Exit.pm
+++ b/scripts/Dpkg/Exit.pm
@@ -75,7 +75,10 @@ Run the registered exit handlers.
 =cut
 
 sub run_exit_handlers {
-$_->() foreach (reverse @handlers);
+while (my $handler = pop @handlers) {
+$handler->();
+}
+_reset_exit_handlers();
 }
 
 sub _exit_handler {
@@ -83,7 +86,7 @@ sub _exit_handler {
 exit(127);
 }
 
-my @SIGNAMES = qw(INT HUP QUIT __DIE__);
+my @SIGNAMES = qw(INT HUP QUIT);
 my %SIGOLD;
 
 sub _setup_exit_handlers
@@ -101,6 +104,10 @@ sub _reset_exit_handlers
 }
 }
 
+END {
+run_exit_handlers();
+}
+
 =back
 
 =head1 CHANGES
diff --git a/scripts/t/Dpkg_Exit.t b/scripts/t/Dpkg_Exit.t
index b4b15e405..663dfc96b 100644
--- a/scripts/t/Dpkg_Exit.t
+++ b/scripts/t/Dpkg_Exit.t
@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 5;
+use Test::More tests => 7;
 
 BEGIN {
 use_ok('Dpkg::Exit');
@@ -51,7 +51,17 @@ sub exit_handler {
 exit 0;
 }
 
+sub ini_handler {
+pass('ini handler invoked');
+}
+
+sub end_handler {
+pass('end handler invoked');
+}
+
+Dpkg::Exit::push_exit_handler(\&end_handler);
 Dpkg::Exit::push_exit_handler(\&exit_handler);
+Dpkg::Exit::push_exit_handler(\&ini_handler);
 
 kill 'INT', $$;
 

-- 
Dpkg.Org's dpkg



[dpkg] 50/68: libdpkg: Do not forget not-installed packages that are set on hold

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=c89140d8bfe69637e50d25949c655cd03d19c6ab

commit c89140d8bfe69637e50d25949c655cd03d19c6ab
Author: Guillem Jover 
AuthorDate: Fri Nov 13 21:01:05 2020 +0100

libdpkg: Do not forget not-installed packages that are set on hold

These are used to denote that the package is not to be installed.

Reported-by: David Kalnischkies 
---
 lib/dpkg/parse.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index c4e5cf21c..6b6582a19 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -279,8 +279,7 @@ pkg_parse_verify(struct parsedb_state *ps,
   pkg->status == PKG_STAT_NOTINSTALLED &&
   pkg->eflag == PKG_EFLAG_OK &&
   (pkg->want == PKG_WANT_PURGE ||
-   pkg->want == PKG_WANT_DEINSTALL ||
-   pkg->want == PKG_WANT_HOLD)) {
+   pkg->want == PKG_WANT_DEINSTALL)) {
 pkg_set_want(pkg, PKG_WANT_UNKNOWN);
   }
 

-- 
Dpkg.Org's dpkg



[dpkg] 45/68: dpkg-deb, dpkg-split: Fix time handling to support 64-bit time

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=bab898774c842a53144fe9b6debb10146aeb768a

commit bab898774c842a53144fe9b6debb10146aeb768a
Author: Guillem Jover 
AuthorDate: Wed Sep 2 04:27:22 2020 +0200

dpkg-deb, dpkg-split: Fix time handling to support 64-bit time
---
 dpkg-deb/build.c  | 13 +++--
 dpkg-split/split.c|  9 +
 lib/dpkg/ar.c |  6 +++---
 lib/dpkg/ar.h |  7 ---
 lib/dpkg/pkg-format.c |  4 +++-
 lib/dpkg/t/c-tarextract.c |  2 +-
 lib/dpkg/tarfn.h  |  2 +-
 7 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c
index 7f29ba22f..c8b4f74a7 100644
--- a/dpkg-deb/build.c
+++ b/dpkg-deb/build.c
@@ -29,6 +29,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -425,7 +426,7 @@ gen_dest_pathname_from_pkg(const char *dir, struct pkginfo 
*pkg)
 typedef void filenames_feed_func(const char *dir, int fd_out);
 
 struct tar_pack_options {
-  time_t timestamp;
+  intmax_t timestamp;
   const char *mode;
   bool root_owner_group;
 };
@@ -459,7 +460,7 @@ tarball_pack(const char *dir, filenames_feed_func 
*tar_filenames_feeder,
 if (chdir(dir))
   ohshite(_("failed to chdir to '%.255s'"), dir);
 
-snprintf(mtime, sizeof(mtime), "@%ld", options->timestamp);
+snprintf(mtime, sizeof(mtime), "@%jd", options->timestamp);
 
 command_init(&cmd, TAR, "tar -cf");
 command_add_args(&cmd, "tar", "-cf", "-", "--format=gnu",
@@ -495,14 +496,14 @@ tarball_pack(const char *dir, filenames_feed_func 
*tar_filenames_feeder,
   subproc_reap(pid_tar, "tar -cf", 0);
 }
 
-static time_t
+static intmax_t
 parse_timestamp(const char *value)
 {
-  time_t timestamp;
+  intmax_t timestamp;
   char *end;
 
   errno = 0;
-  timestamp = strtol(value, &end, 10);
+  timestamp = strtoimax(value, &end, 10);
   if (value == end || *end || errno != 0)
 ohshite(_("unable to parse timestamp '%.255s'"), value);
 
@@ -519,7 +520,7 @@ do_build(const char *const *argv)
   struct tar_pack_options tar_options;
   struct dpkg_error err;
   struct dpkg_ar *ar;
-  time_t timestamp;
+  intmax_t timestamp;
   const char *timestamp_str;
   const char *dir, *dest;
   char *ctrldir;
diff --git a/dpkg-split/split.c b/dpkg-split/split.c
index e197b22f2..607222365 100644
--- a/dpkg-split/split.c
+++ b/dpkg-split/split.c
@@ -28,6 +28,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -90,14 +91,14 @@ deb_parse_control(const char *filename)
return pkg;
 }
 
-static time_t
+static intmax_t
 parse_timestamp(const char *value)
 {
-   time_t timestamp;
+   intmax_t timestamp;
char *end;
 
errno = 0;
-   timestamp = strtol(value, &end, 10);
+   timestamp = strtoimax(value, &end, 10);
if (value == end || *end || errno != 0)
ohshite(_("unable to parse timestamp '%.255s'"), value);
 
@@ -132,7 +133,7 @@ mksplit(const char *file_src, const char *prefix, off_t 
maxpartsize,
struct dpkg_error err;
int fd_src;
struct stat st;
-   time_t timestamp;
+   intmax_t timestamp;
const char *timestamp_str;
const char *version;
char hash[MD5HASHLEN + 1];
diff --git a/lib/dpkg/ar.c b/lib/dpkg/ar.c
index 444b10cf7..57d304ce8 100644
--- a/lib/dpkg/ar.c
+++ b/lib/dpkg/ar.c
@@ -84,7 +84,7 @@ dpkg_ar_create(const char *filename, mode_t mode)
 }
 
 void
-dpkg_ar_set_mtime(struct dpkg_ar *ar, time_t mtime)
+dpkg_ar_set_mtime(struct dpkg_ar *ar, intmax_t mtime)
 {
ar->time = mtime;
 }
@@ -174,8 +174,8 @@ dpkg_ar_member_put_header(struct dpkg_ar *ar, struct 
dpkg_ar_member *member)
ohshit(_("ar member size %jd too large"), 
(intmax_t)member->size);
 
n = snprintf(header, sizeof(struct dpkg_ar_hdr) + 1,
-"%-16s%-12lu%-6lu%-6lu%-8lo%-10jd`\n",
-member->name, (unsigned long)member->time,
+"%-16s%-12jd%-6lu%-6lu%-8lo%-10jd`\n",
+member->name, (intmax_t)member->time,
 (unsigned long)member->uid, (unsigned long)member->gid,
 (unsigned long)member->mode, (intmax_t)member->size);
if (n != sizeof(struct dpkg_ar_hdr))
diff --git a/lib/dpkg/ar.h b/lib/dpkg/ar.h
index 55bfa6e99..680c13d2e 100644
--- a/lib/dpkg/ar.h
+++ b/lib/dpkg/ar.h
@@ -24,6 +24,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 #include 
@@ -57,7 +58,7 @@ struct dpkg_ar_hdr {
 struct dpkg_ar {
const char *name;
mode_t mode;
-   time_t time;
+   intmax_t time;
off_t size;
int fd;
 };
@@ -70,7 +71,7 @@ struct dpkg_ar_member {
const char *name;
off_t offset;
off_t size;
-   time_t time;
+   intmax_t time;
mode_t mode;
uid_t uid;
 

[dpkg] 05/68: build: Pre-process the curses header before parsing it

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=15f285b9d0a00fd07931fff051f7803852d612af

commit 15f285b9d0a00fd07931fff051f7803852d612af
Author: Guillem Jover 
AuthorDate: Sat Sep 19 23:09:52 2020 +0200

build: Pre-process the curses header before parsing it

We need to extract the KEY_* macros from the curses header file that
we are going to end up including in the source. But we should not
assume any kind of structure, because that's just fragile, as the
contents can be included from other header files, or be protected
behind a pre-processor macro or similar.

Instead we use the CPP -dD option which will make the pre-processor
handle all the internal details and output a list of active macros
with their values, which we can then safely parse.

Closes: #970545
---
 dselect/.gitignore  |  1 +
 dselect/Makefile.am | 16 ++--
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/dselect/.gitignore b/dselect/.gitignore
index cce16ad58..bba6d3455 100644
--- a/dselect/.gitignore
+++ b/dselect/.gitignore
@@ -1,2 +1,3 @@
 curkeys.h
+curkeys.hpp
 dselect
diff --git a/dselect/Makefile.am b/dselect/Makefile.am
index 9206603a2..4671c7ba6 100644
--- a/dselect/Makefile.am
+++ b/dselect/Makefile.am
@@ -57,18 +57,14 @@ dselect_LDADD = \
 
 
 EXTRA_DIST = keyoverride mkcurkeys.pl
-CLEANFILES = curkeys.h
+CLEANFILES = curkeys.hpp curkeys.h
 
 curkeys.$(OBJEXT): curkeys.h
-curkeys.h: $(srcdir)/keyoverride $(srcdir)/mkcurkeys.pl
-   $(AM_V_GEN) cursesfile=`echo '#include "dselect-curses.h"' | \
- $(CPP) $(CPPFLAGS) -I$(top_builddir) -I $(srcdir) - | \
- grep '[^-]curses\.h' | head -n 1 | \
- sed -e 's/^[^"]*"//; s/".*$$//'`; \
-   if [ "$$cursesfile" = "" ]; then \
- echo "can't find curses file"; exit 1; \
-   fi; \
-   $(PERL) $(srcdir)/mkcurkeys.pl $< $$cursesfile >$@
+curkeys.hpp: dselect-curses.h
+   $(AM_V_GEN) echo '#include "dselect-curses.h"' | \
+ $(CPP) -dD $(CPPFLAGS) -I$(top_builddir) -I $(srcdir) - >$@
+curkeys.h: $(srcdir)/keyoverride $(srcdir)/mkcurkeys.pl curkeys.hpp
+   $(AM_V_GEN) $(PERL) $(srcdir)/mkcurkeys.pl $< curkeys.hpp >$@
 
 install-data-local:
$(MKDIR_P) $(DESTDIR)$(pkgconfdir)/dselect.cfg.d

-- 
Dpkg.Org's dpkg



[dpkg] 04/68: build: Add new gen-changelog tool

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=68ed7b9d987beb7bd5e5d92a97a7cad319a594c0

commit 68ed7b9d987beb7bd5e5d92a97a7cad319a594c0
Author: Guillem Jover 
AuthorDate: Sun Nov 8 03:48:57 2020 +0100

build: Add new gen-changelog tool

This tool will assist in preparing the debian/changelog out of the
git log, by using the specially formatted commit messages and meta
fields.
---
 Makefile.am   |   1 +
 gen-changelog | 284 ++
 2 files changed, 285 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index 2e4acce20..abd650f80 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -59,6 +59,7 @@ EXTRA_DIST = \
ChangeLog.old \
README.l10n \
autogen \
+   gen-changelog \
get-version \
run-script \
doc/coding-style.txt \
diff --git a/gen-changelog b/gen-changelog
new file mode 100755
index 0..bc6bdf57f
--- /dev/null
+++ b/gen-changelog
@@ -0,0 +1,284 @@
+#!/usr/bin/perl
+#
+# gen-changelog
+#
+# Copyright © 2020 Guillem Jover 
+#
+# 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, see .
+#
+
+use strict;
+use warnings;
+
+use lib 'scripts';
+
+use List::Util qw(uniq);
+use Text::Wrap;
+use Dpkg::IPC;
+use Dpkg::Index;
+
+sub gen_l10n_group
+{
+my $commit = shift;
+my $title = $commit->{Title} =~ s/^po: //r;
+
+if ($title =~ m/^Regenerate/) {
+# Skip.
+return;
+} elsif ($title =~ /^(Update|Add) ([A-Za-z ]+) (program|script|dselect|man 
page)s? translations?/) {
+my ($action, $lang, $part) = ($1, $2, $3);
+
+$part .= 's' if $part ne 'dselect';
+$commit->{Title} = "$lang ($commit->{Author})";
+
+return ('l10n', "$action $part translations");
+} else {
+return ('main', $commit->{Committer});
+}
+}
+
+my @sections = qw(
+main
+arch
+port
+perl-mod
+doc
+code-int
+build-sys
+pkg
+test
+l10n
+);
+
+my %sections = (
+arch => {
+title => 'Architecture support',
+match => qr/^arch: /,
+},
+port => {
+title => 'Portability',
+type => 'porting',
+},
+'perl-mod' => {
+title => 'Perl modules',
+match => qr/^Dpkg.*[,:] /,
+keep => 1,
+},
+doc => {
+title => 'Documentation',
+match => qr/^(?:doc|man)[,:] /,
+keep => 1,
+},
+'code-int' => {
+title => 'Code internals',
+type => 'internal',
+},
+'build-sys' => {
+title => 'Build system',
+match => qr/^build: /,
+},
+pkg => {
+title => 'Packaging',
+match => qr/^debian: /,
+},
+test => {
+title => 'Test suite',
+match => qr/^(?:test|t): /,
+},
+l10n => {
+title => 'Localization',
+group => \&gen_l10n_group,
+match => qr/^po: /,
+},
+);
+
+my %metafield = (
+'Co-Author' => 'Co-authored by',
+'Based-on-patch-by' => 'Based on a patch by',
+'Improved-by' => 'Improved by',
+'Prompted-by' => 'Prompted by',
+'Reported-by' => 'Reported by',
+'Required-by' => 'Required by',
+'Analysis-by' => 'Anaylisis by',
+'Requested-by' => 'Requested by',
+'Suggested-by' => 'Suggested by',
+'Spotted-by' => 'Spotted by',
+'Naming-by' => 'Naming by',
+'Thanks-to' => 'Thanks to',
+'Ref' => 'See',
+);
+
+my %mappings = (
+'u-a' => 'update-alternatives',
+'s-s-d' => 'start-stop-daemon',
+);
+
+my $log_format =
+'Commit: %H%n' .
+'Author: %aN%n' .
+'AuthorEmail: %aE%n' .
+'Committer: %cN%n' .
+'CommitterEmail: %cE%n' .
+'Title: %s%n' .
+'%(trailers:only,unfold)';
+
+my $tag_prev = qx(git describe --abbrev=0);
+chomp $tag_prev;
+
+my $fh_gitlog;
+
+spawn(
+exec => [
+qw(git log --no-merges), "--format=tformat:$log_format", "$tag_prev.."
+],
+to_pipe => \$fh_gitlog,
+);
+
+my $log = Dpkg::Index->new(
+get_key_func => sub { return $_[0]->{Commit} },
+item_opts => {
+allow_duplicate => 1,
+},
+);
+$log->parse($fh_gitlog, 'git log');
+
+my %entries;
+my %groups;
+my (@groups, @groups_l10n);
+
+# Analyze the commits and select which group and section to place them in.
+foreach

[dpkg] 28/68: libdpkg: Fix memory leaks in tar_extractor()

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=cf8fe0d6e74fdc6970ceb17e44ec9f67901120b8

commit cf8fe0d6e74fdc6970ceb17e44ec9f67901120b8
Author: Guillem Jover 
AuthorDate: Sun Aug 16 23:02:56 2020 +0200

libdpkg: Fix memory leaks in tar_extractor()

We need to free the members when assigning into them for the GNU
longlink and longname extensions.

Warned-by: gcc ASAN
Stable-Candidate: 1.19.x
---
 lib/dpkg/tarfn.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/dpkg/tarfn.c b/lib/dpkg/tarfn.c
index a0821f217..41641b934 100644
--- a/lib/dpkg/tarfn.c
+++ b/lib/dpkg/tarfn.c
@@ -474,11 +474,15 @@ tar_extractor(struct tar_archive *tar)
}
if (h.type != TAR_FILETYPE_GNU_LONGLINK &&
h.type != TAR_FILETYPE_GNU_LONGNAME) {
-   if (next_long_name)
+   if (next_long_name) {
+   free(h.name);
h.name = next_long_name;
+   }
 
-   if (next_long_link)
+   if (next_long_link) {
+   free(h.linkname);
h.linkname = next_long_link;
+   }
 
next_long_link = NULL;
next_long_name = NULL;

-- 
Dpkg.Org's dpkg



[dpkg] 65/68: Dpkg::Source::Package: Honor no_check for directory traversal checks

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=157a4e6c0f1dda42b1ae3bae8086a9a64d85e2f9

commit 157a4e6c0f1dda42b1ae3bae8086a9a64d85e2f9
Author: Guillem Jover 
AuthorDate: Mon Nov 2 11:15:47 2020 +0100

Dpkg::Source::Package: Honor no_check for directory traversal checks

While this is a potential security issue, we should let the user disable
the check in case it has been requested explicitly.

Ref: #971203
---
 scripts/Dpkg/Source/Package.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm
index 1b52b0ee3..19a49eeba 100644
--- a/scripts/Dpkg/Source/Package.pm
+++ b/scripts/Dpkg/Source/Package.pm
@@ -553,7 +553,7 @@ sub extract {
 $self->do_extract($newdirectory);
 
 # Check for directory traversals.
-if (not $self->{options}{skip_debianization}) {
+if (not $self->{options}{skip_debianization} and not $self->{no_check}) {
 # We need to add a trailing slash to handle the debian directory
 # possibly being a symlink.
 check_directory_traversal($newdirectory, "$newdirectory/debian/");

-- 
Dpkg.Org's dpkg



[dpkg] 21/68: libcompat, dpkg: Stop using deprecated security_context_t data type

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=ee479e2c0764bc4902f9141ac886a8a7c8fffcd9

commit ee479e2c0764bc4902f9141ac886a8a7c8fffcd9
Author: Guillem Jover 
AuthorDate: Mon Aug 3 23:39:41 2020 +0200

libcompat, dpkg: Stop using deprecated security_context_t data type

This got deprecated upstream in 2014, but only in 2020 the type started
to emit deprecation warnings.

Changelog: internal
---
 lib/compat/selinux.c | 3 +--
 src/selinux.c| 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/compat/selinux.c b/lib/compat/selinux.c
index 9e50e03d8..dc651f5c2 100644
--- a/lib/compat/selinux.c
+++ b/lib/compat/selinux.c
@@ -40,8 +40,7 @@ int
 setexecfilecon(const char *filename, const char *fallback)
 {
int rc;
-
-   security_context_t curcon = NULL, newcon = NULL, filecon = NULL;
+   char *curcon = NULL, *newcon = NULL, *filecon = NULL;
security_class_t seclass;
context_t tmpcon = NULL;
 
diff --git a/src/selinux.c b/src/selinux.c
index 2218bd2ed..de361aa8d 100644
--- a/src/selinux.c
+++ b/src/selinux.c
@@ -86,7 +86,7 @@ void
 dpkg_selabel_set_context(const char *matchpath, const char *path, mode_t mode)
 {
 #ifdef WITH_LIBSELINUX
-   security_context_t scontext = NULL;
+   char *scontext = NULL;
int ret;
 
/* If SELinux is not enabled just do nothing. */

-- 
Dpkg.Org's dpkg



[dpkg] 24/68: test: Fix short lived memory leaks in unit tests

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=e93d0e5d70fa36aa307a6ecaed433b8377c037bf

commit e93d0e5d70fa36aa307a6ecaed433b8377c037bf
Author: Guillem Jover 
AuthorDate: Sun Aug 16 22:54:39 2020 +0200

test: Fix short lived memory leaks in unit tests

These are inconsequential, but shadow actual memory leaks from being
detected by address sanitizers or similar tools.

Warned-by: gcc ASAN
---
 lib/dpkg/t/c-tarextract.c | 2 ++
 lib/dpkg/t/t-arch.c   | 2 ++
 lib/dpkg/t/t-buffer.c | 2 ++
 lib/dpkg/t/t-command.c| 2 ++
 lib/dpkg/t/t-file.c   | 2 ++
 5 files changed, 10 insertions(+)

diff --git a/lib/dpkg/t/c-tarextract.c b/lib/dpkg/t/c-tarextract.c
index a2cd6972a..461f77f4a 100644
--- a/lib/dpkg/t/c-tarextract.c
+++ b/lib/dpkg/t/c-tarextract.c
@@ -140,6 +140,8 @@ main(int argc, char **argv)
if (tar_extractor(&tar))
ohshite("extracting tar");
 
+   dpkg_error_destroy(&tar.err);
+
if (tar_name)
close(tar_ctx.tar_fd);
 
diff --git a/lib/dpkg/t/t-arch.c b/lib/dpkg/t/t-arch.c
index 55c6ea32a..430980ee3 100644
--- a/lib/dpkg/t/t-arch.c
+++ b/lib/dpkg/t/t-arch.c
@@ -186,6 +186,8 @@ test_dpkg_arch_varbuf_archqual(void)
varbuf_end_str(&vb);
test_str(vb.buf, ==, ":any");
varbuf_reset(&vb);
+
+   varbuf_destroy(&vb);
 }
 
 static void
diff --git a/lib/dpkg/t/t-buffer.c b/lib/dpkg/t/t-buffer.c
index 2847e9373..fa939e55d 100644
--- a/lib/dpkg/t/t-buffer.c
+++ b/lib/dpkg/t/t-buffer.c
@@ -69,6 +69,8 @@ test_fdio_hash(void)
test_str(hash, ==, ref_hash_test);
 
test_pass(unlink(test_file) == 0);
+
+   free(test_file);
 }
 
 TEST_ENTRY(test)
diff --git a/lib/dpkg/t/t-command.c b/lib/dpkg/t/t-command.c
index 099884560..4c360064c 100644
--- a/lib/dpkg/t/t-command.c
+++ b/lib/dpkg/t/t-command.c
@@ -180,6 +180,8 @@ test_command_exec(void)
 
ret = subproc_reap(pid, "command exec test", 0);
test_pass(ret == 0);
+
+   command_destroy(&cmd);
 }
 
 static void
diff --git a/lib/dpkg/t/t-file.c b/lib/dpkg/t/t-file.c
index ca68eaefe..278df9141 100644
--- a/lib/dpkg/t/t-file.c
+++ b/lib/dpkg/t/t-file.c
@@ -63,6 +63,7 @@ test_file_slurp(void)
test_error(err);
varbuf_destroy(&vb);
test_pass(rmdir(test_dir) == 0);
+   free(test_dir);
 
test_file = test_alloc(strdup("test.XX"));
fd = mkstemp(test_file);
@@ -86,6 +87,7 @@ test_file_slurp(void)
varbuf_destroy(&vb);
 
test_pass(unlink(test_file) == 0);
+   free(test_file);
 }
 
 TEST_ENTRY(test)

-- 
Dpkg.Org's dpkg



[dpkg] 22/68: debian: Do not fail the bug-script if readlink fails

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=7d3eb5a6f16c936d502f776783051e24016613ed

commit 7d3eb5a6f16c936d502f776783051e24016613ed
Author: Guillem Jover 
AuthorDate: Fri Aug 14 18:54:15 2020 +0200

debian: Do not fail the bug-script if readlink fails

When readlink fails inside a $() the whole script fails. Remove the
«set -e» from the bug-script, as making it fail will cause programs
like reportbug to make it way harder to report bugs, which is
counterproductive.

Closes: #968397
---
 debian/bug-script | 2 --
 1 file changed, 2 deletions(-)

diff --git a/debian/bug-script b/debian/bug-script
index ae3b40296..835c36f91 100644
--- a/debian/bug-script
+++ b/debian/bug-script
@@ -1,7 +1,5 @@
 #!/bin/sh
 
-set -e
-
 for d in /bin /sbin /lib /lib32 /libo32 /libx32 /lib64; do
   linkname="$(readlink $d)"
   if [ "$linkname" = "usr$d" ] || [ "$linkname" = "/usr$d" ]; then

-- 
Dpkg.Org's dpkg



[dpkg] 62/68: test: Use intermediate variable for directory traversal item iteration

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=0b521d2147872e18e5ce2919f17d3a41661baa7f

commit 0b521d2147872e18e5ce2919f17d3a41661baa7f
Author: Guillem Jover 
AuthorDate: Sun Nov 22 23:56:52 2020 +0100

test: Use intermediate variable for directory traversal item iteration
---
 scripts/t/Dpkg_Path.t | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/t/Dpkg_Path.t b/scripts/t/Dpkg_Path.t
index b626a8de2..7d753a274 100644
--- a/scripts/t/Dpkg_Path.t
+++ b/scripts/t/Dpkg_Path.t
@@ -206,10 +206,11 @@ my %travtype = (
 make_path($travbase_out);
 
 foreach my $travtype (sort keys %travtype) {
+my $trav = $travtype{$travtype};
 my $travdir = "$travbase/$travtype";
 
 gen_hier_travbase($travdir);
-$travtype{$travtype}->{gen}->($travdir);
+$trav->{gen}->($travdir);
 
 my $catch;
 eval {
@@ -218,7 +219,7 @@ foreach my $travtype (sort keys %travtype) {
 } or do {
 $catch = $@;
 };
-if ($travtype{$travtype}->{fail}) {
+if ($trav->{fail}) {
 ok($catch, "directory traversal type $travtype detected");
 note("traversal reason: $catch") if $catch;
 } else {

-- 
Dpkg.Org's dpkg



[dpkg] 37/68: dpkg-deb: Fix single-instance memory leak on missing conffiles control file

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=c720bbd7a97bfb5ec547da10da5e2322a8e4c0b8

commit c720bbd7a97bfb5ec547da10da5e2322a8e4c0b8
Author: Guillem Jover 
AuthorDate: Wed Sep 2 04:23:11 2020 +0200

dpkg-deb: Fix single-instance memory leak on missing conffiles control file

This gets leaked just once while checking the conffile control file.

Warned-by: gcc ASAN
---
 dpkg-deb/build.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c
index faaf09122..7f29ba22f 100644
--- a/dpkg-deb/build.c
+++ b/dpkg-deb/build.c
@@ -259,8 +259,10 @@ check_conffiles(const char *ctrldir, const char *rootdir)
 
   cf = fopen(controlfile.buf, "r");
   if (cf == NULL) {
-if (errno == ENOENT)
+if (errno == ENOENT) {
+  varbuf_destroy(&controlfile);
   return;
+}
 
 ohshite(_("error opening conffiles file"));
   }

-- 
Dpkg.Org's dpkg



[dpkg] 51/68: u-a: Refactor alternative database context freeing into a new function

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=9b8f4296cf0b0f3a4aecc59d5d96d2b5f3ad2218

commit 9b8f4296cf0b0f3a4aecc59d5d96d2b5f3ad2218
Author: Guillem Jover 
AuthorDate: Tue Aug 25 01:13:12 2020 +0200

u-a: Refactor alternative database context freeing into a new function

Changelog: internal
---
 utils/update-alternatives.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 71e4879d6..b98fbe1a6 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -1229,6 +1229,14 @@ struct altdb_context {
jmp_buf on_error;
 };
 
+static void
+altdb_context_free(struct altdb_context *ctx)
+{
+   if (ctx->fh)
+   fclose(ctx->fh);
+   free(ctx->filename);
+}
+
 static int
 altdb_filter_namelist(const struct dirent *entry)
 {
@@ -1464,9 +1472,7 @@ alternative_load(struct alternative *a, enum altdb_flags 
flags)
}
 
if (setjmp(ctx.on_error)) {
-   if (ctx.fh)
-   fclose(ctx.fh);
-   free(ctx.filename);
+   altdb_context_free(&ctx);
alternative_reset(a);
return false;
}

-- 
Dpkg.Org's dpkg



[dpkg] branch master updated (9e0c88ec0 -> b51030bd7)

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a change to branch master
in repository dpkg.

from 9e0c88ec0 Bump version to 1.20.6
 new c4d7c906e po: Add Portuguese man pages translation
 new 511f7183d doc: Update l10n commit documentation
 new 41a98902a Dpkg::Index: Add new item_opts option
 new 68ed7b9d9 build: Add new gen-changelog tool
 new 15f285b9d build: Pre-process the curses header before parsing it
 new cdb7949e6 build: Fix variable substitution in man pages
 new e56a8172e build: Add a README.cpan to be installed as README in the 
CPAN distribution
 new 631b7591c build: Do not try to use  on GNU/Linux
 new c2f6c4acd man: Fix typo in --print-unset option reference
 new 4d0b9a355 man: Clarify that dpkg-architecture uses some of its own 
variables
 new 0c782cc23 man: Fix casing and namespacing in VARIABLES definitions
 new bec9f5011 man: Fix typo in dpkg-source(1)
 new 9fabaf3b4 man: Add a reference to deb-symbols(5) in deb-src-symbols(5) 
DESCRIPTION
 new 7a92a1448 man: Specify that symbol, version and id are separated by a 
single whitespace
 new 05264f16e man: Clarify day-of-month format in deb-changelog(5)
 new 97eee9cd5 man: Update u-a maintainer script usage information
 new 20e42a6a8 man: Switch to use L<> markup for URLs instead of B<>
 new 5b195d417 man: Remove trailing blank lines
 new 3fb87b5c6 doc, man: Clarify that R³ values are case sensitive
 new ddbec2477 man: Add references to deb822(5) to file formats based on it
 new ee479e2c0 libcompat, dpkg: Stop using deprecated security_context_t 
data type
 new 7d3eb5a6f debian: Do not fail the bug-script if readlink fails
 new 25797abf7 debian: Improve cron file robustness on missing or empty 
backup files
 new e93d0e5d7 test: Fix short lived memory leaks in unit tests
 new 52ab5b4cb test: Print the ehandle unit test error output on verbose 
mode
 new 7d2d5be9f test: Improve dpkg-divert test to output stdout and stderr
 new 52b63137c libdpkg: Fix undefined behavior in varbuf functions
 new cf8fe0d6e libdpkg: Fix memory leaks in tar_extractor()
 new 35d024ea7 libdpkg: Fix memory leak in trigger deferred processing
 new 7fa28dce1 libdpkg: Fix memory leak in filesystem treewalk node free 
function
 new 406af89c0 libdpkg: Fix memory leak in filesystem treewalk iterator
 new f13aebc8a libdpkg: Fix single-instance memory leak with fsys dir
 new 38cb8160e libdpkg: Fix short-lived memory leaks
 new 889848ed5 libdpkg: Reset error context errmsg after free()
 new 60dba33b1 dpkg: Fix memory leak for cidir
 new c1068bb2e dpkg: Fix short-lived memory leak in --force-help output
 new c720bbd7a dpkg-deb: Fix single-instance memory leak on missing 
conffiles control file
 new 1dd925c87 dpkg-divert: Fix short-lived memory leaks
 new fd4d04484 dpkg-realpath: Add new -z, --zero option
 new 11a8426fb dpkg-deb: Make decompression error message more descriptive
 new 7c54fa2b2 dpkg-architecture: Add a --print-format option
 new 7e2cb252d dpkg-buildpackage: Warn on known R³ values in uppercase
 new fae07d08c dpkg-buildpackage: Error out on R³ "yes" value
 new a048b1c20 dpkg-buildpackage: Clarify R³ keyword diagnostic messages
 new bab898774 dpkg-deb, dpkg-split: Fix time handling to support 64-bit 
time
 new b885b7344 libdpkg: Check that the ar archive time is within bounds
 new 536a38582 libdpkg: Ignore not-installed packages for source related 
virtual fields
 new 9022f9e0f libdpkg: Make source version parsing more robust on missing 
data
 new 96005ddd9 libdpkg: Fix typo in comment
 new c89140d8b libdpkg: Do not forget not-installed packages that are set 
on hold
 new 9b8f4296c u-a: Refactor alternative database context freeing into a 
new function
 new 2096f4fe2 u-a: Fix memory leaks for alternative database context on 
load errors
 new 0d26b9fca u-a: Fix typos in code comments
 new 55700d232 u-a: Fix short-lived memory leaks for alternative structs
 new c86dcd9c9 u-a: Fix memory leaks with new_choice
 new 6bf600602 u-a: Fix short-lived memory leaks for log_file and admdir
 new 6d03bf8df Dpkg::Exit: Fix exit handler on program termination
 new 2fc935f12 Dpkg::Changelog::Entry::Debian: Fix format string
 new 6b15c47b7 Dpkg::Changelog::Parse: Add new verbose option
 new 3b9afd43d Dpkg::Changelog::Parse: Document 'label' option
 new a40c250be Dpkg::Source::Package::V1: Print a message when verifying 
tarball signatures
 new 0b521d214 test: Use intermediate variable for directory traversal item 
iteration
 new 1ddcd026b test: Refactor root handling in Dpkg::Path unit tests
 new 727edc4d2 Dpkg::Path: Fix pathname traversal check for symlinks
 new 157a4e6c0 Dpkg::Source::Package: Honor no_check for directory 
traversal checks
 new 9e34f5c14 Dpkg::Source::Package: Call 

[dpkg] 31/68: libdpkg: Fix memory leak in filesystem treewalk iterator

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=406af89c075f5ac0915e3dff19d1287b0876853c

commit 406af89c075f5ac0915e3dff19d1287b0876853c
Author: Guillem Jover 
AuthorDate: Fri Aug 21 03:42:30 2020 +0200

libdpkg: Fix memory leak in filesystem treewalk iterator

We need to free the last element from the tree.

Warned-by: gcc ASAN
Stable-Candidate: 1.19.x
---
 lib/dpkg/treewalk.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/dpkg/treewalk.c b/lib/dpkg/treewalk.c
index 3277f3131..08b70f34c 100644
--- a/lib/dpkg/treewalk.c
+++ b/lib/dpkg/treewalk.c
@@ -489,8 +489,10 @@ treewalk_next(struct treeroot *tree)
break;
}
 
-   if (tree->curdir == NULL)
+   if (tree->curdir == NULL) {
+   treenode_free_node(tree->rootnode);
break;
+   }
}
 
treeroot_set_curnode(tree, node);

-- 
Dpkg.Org's dpkg



[dpkg] 07/68: build: Add a README.cpan to be installed as README in the CPAN distribution

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=e56a8172e3c3344d41592191734829d4afba6ce2

commit e56a8172e3c3344d41592191734829d4afba6ce2
Author: Guillem Jover 
AuthorDate: Mon Nov 2 10:06:47 2020 +0100

build: Add a README.cpan to be installed as README in the CPAN distribution

This is a requirement for the CPAN distributions.
---
 configure.ac   | 1 +
 cpan.am| 1 +
 scripts/.gitignore | 1 +
 scripts/README.cpan.in | 5 +
 4 files changed, 8 insertions(+)

diff --git a/configure.ac b/configure.ac
index 16800e8e8..5ca23b4cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -226,6 +226,7 @@ AC_CONFIG_FILES([
   po/Makefile.in
   scripts/Build.PL
   scripts/Makefile
+  scripts/README.cpan
   scripts/mk/Makefile
   scripts/po/Makefile.in
   src/Makefile
diff --git a/cpan.am b/cpan.am
index 4c72d9187..a9c12497e 100644
--- a/cpan.am
+++ b/cpan.am
@@ -21,6 +21,7 @@ dist-cpan:
cp -fpR $(top_srcdir)/scripts/Dpkg.pm $(CPAN_DIST)/lib/
cp -fpR $(top_srcdir)/scripts/Dpkg $(CPAN_DIST)/lib/
cp -fpR $(top_srcdir)/scripts/Test $(CPAN_DIST)/lib/
+   cp -fpR $(top_builddir)/scripts/README.cpan $(CPAN_DIST)/README
cp -fpR $(top_builddir)/scripts/Build.PL $(CPAN_DIST)
 
: # Fix permissions of the distributed files.
diff --git a/scripts/.gitignore b/scripts/.gitignore
index f10602c23..99f6d0900 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -1,4 +1,5 @@
 Build.PL
+README.cpan
 dpkg-architecture
 dpkg-buildflags
 dpkg-buildpackage
diff --git a/scripts/README.cpan.in b/scripts/README.cpan.in
new file mode 100644
index 0..5bf8161c5
--- /dev/null
+++ b/scripts/README.cpan.in
@@ -0,0 +1,5 @@
+This archive contains the CPAN distribution for @PACKAGE_CPAN_NAME@, which
+is part of the @PACKAGE@ project.
+
+Only the perl modules are included. The rest of the content can be found in
+the original upstream source code, from <@PACKAGE_URL@>.

-- 
Dpkg.Org's dpkg



[dpkg] 68/68: Dpkg::OpenPGP: Refactor gpg armor code into its own function

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=b51030bd7d72614b8b66204afbd86047c0538039

commit b51030bd7d72614b8b66204afbd86047c0538039 (HEAD -> master)
Author: Guillem Jover 
AuthorDate: Thu Nov 12 13:54:48 2020 +0100

Dpkg::OpenPGP: Refactor gpg armor code into its own function
---
 scripts/Dpkg/OpenPGP.pm | 48 +++-
 1 file changed, 27 insertions(+), 21 deletions(-)

diff --git a/scripts/Dpkg/OpenPGP.pm b/scripts/Dpkg/OpenPGP.pm
index cf1b46610..79840a026 100644
--- a/scripts/Dpkg/OpenPGP.pm
+++ b/scripts/Dpkg/OpenPGP.pm
@@ -33,6 +33,30 @@ our @EXPORT = qw(
 openpgp_sig_to_asc
 );
 
+sub _armor_gpg {
+my ($sig, $asc) = @_;
+
+my @gpg_opts = qw(--no-options);
+
+open my $fh_asc, '>', $asc
+or syserr(g_('cannot create signature file %s'), $asc);
+open my $fh_gpg, '-|', 'gpg', @gpg_opts, '-o', '-', '--enarmor', $sig
+or syserr(g_('cannot execute %s program'), 'gpg');
+while (my $line = <$fh_gpg>) {
+next if $line =~ m/^Version: /;
+next if $line =~ m/^Comment: /;
+
+$line =~ s/ARMORED FILE/SIGNATURE/;
+
+print { $fh_asc } $line;
+}
+
+close $fh_gpg or subprocerr('gpg');
+close $fh_asc or syserr(g_('cannot write signature file %s'), $asc);
+
+return $asc;
+}
+
 sub openpgp_sig_to_asc
 {
 my ($sig, $asc) = @_;
@@ -55,29 +79,11 @@ sub openpgp_sig_to_asc
 return $asc;
 }
 
-if (not find_command('gpg')) {
+if (find_command('gpg')) {
+return _armor_gpg($sig, $asc);
+} else {
 warning(g_('cannot OpenPGP ASCII armor signature file due to 
missing gpg'));
 }
-
-my @gpg_opts = qw(--no-options);
-
-open my $fh_asc, '>', $asc
-or syserr(g_('cannot create signature file %s'), $asc);
-open my $fh_gpg, '-|', 'gpg', @gpg_opts, '-o', '-', '--enarmor', $sig
-or syserr(g_('cannot execute %s program'), 'gpg');
-while (my $line = <$fh_gpg>) {
-next if $line =~ m/^Version: /;
-next if $line =~ m/^Comment: /;
-
-$line =~ s/ARMORED FILE/SIGNATURE/;
-
-print { $fh_asc } $line;
-}
-
-close $fh_gpg or subprocerr('gpg');
-close $fh_asc or syserr(g_('cannot write signature file %s'), $asc);
-
-return $asc;
 }
 
 return;

-- 
Dpkg.Org's dpkg



[dpkg] 63/68: test: Refactor root handling in Dpkg::Path unit tests

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=1ddcd026b53f4471433e411ebaf9be18cf08365a

commit 1ddcd026b53f4471433e411ebaf9be18cf08365a
Author: Guillem Jover 
AuthorDate: Mon Sep 28 02:44:10 2020 +0200

test: Refactor root handling in Dpkg::Path unit tests

Add support for alternative root directories to Dpkg::Path tests, to
make possible to create hierarchies that might trip over conditions
in other checks into their own root directory, and to simplify
Dpkg_Path unit tests by using the new root and chroot options in
%travtype.
---
 scripts/t/Dpkg_Path.t | 30 +-
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/scripts/t/Dpkg_Path.t b/scripts/t/Dpkg_Path.t
index 7d753a274..bfd5b8db5 100644
--- a/scripts/t/Dpkg_Path.t
+++ b/scripts/t/Dpkg_Path.t
@@ -20,7 +20,7 @@ use Test::More tests => 33;
 use Test::Dpkg qw(:paths);
 
 use Cwd qw(realpath);
-use File::Path qw(make_path);;
+use File::Path qw(make_path rmtree);
 use File::Spec::Functions qw(abs2rel);
 
 use_ok('Dpkg::Path', 'canonpath', 'resolve_symlink',
@@ -168,49 +168,45 @@ my %travtype = (
 },
 base_out_empty => {
 fail => 1,
+root => $travbase_out,
 gen => sub {
 my $basedir = shift;
-rename $basedir, "$travbase_out/base_out_empty-disabled";
-symlink abs2rel("$travbase_out/base_out_empty", $travbase), 
$basedir;
-make_path("$travbase_out/base_out_empty");
+rmtree($basedir);
+make_path($basedir);
 },
 },
 base_out_none => {
 fail => 1,
-gen => sub {
-my $basedir = shift;
-rename $basedir, "$travbase_out/base_out_none";
-symlink abs2rel("$travbase_out/base_out_none", $travbase), 
$basedir;
-},
+root => $travbase_out,
+gen => sub { },
 },
 base_out_rel => {
 fail => 1,
+root => $travbase_out,
 gen => sub {
 my $basedir = shift;
-rename $basedir, "$travbase_out/base_out_rel";
-symlink abs2rel("$travbase_out/base_out_rel", $travbase), $basedir;
 symlink '../../..', "$basedir/rel";
 },
 },
 base_out_abs => {
 fail => 1,
+root => $travbase_out,
 gen => sub {
 my $basedir = shift;
-rename $basedir, "$travbase_out/base_out_abs";
-symlink abs2rel("$travbase_out/base_out_abs", $travbase), $basedir;
 symlink '/etc', "$basedir/abs";
 },
 },
 );
 
-make_path($travbase_out);
-
 foreach my $travtype (sort keys %travtype) {
 my $trav = $travtype{$travtype};
+my $rootdir = $trav->{chroot} // $trav->{root} // $travbase;
+my $hierdir = "$rootdir/$travtype";
 my $travdir = "$travbase/$travtype";
 
-gen_hier_travbase($travdir);
-$trav->{gen}->($travdir);
+gen_hier_travbase($hierdir);
+symlink abs2rel($hierdir, $travbase), $travdir if exists $trav->{root};
+$trav->{gen}->($hierdir);
 
 my $catch;
 eval {

-- 
Dpkg.Org's dpkg



[dpkg] 30/68: libdpkg: Fix memory leak in filesystem treewalk node free function

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=7fa28dce1e3a6ab4d317a2ebf8efc92f57237038

commit 7fa28dce1e3a6ab4d317a2ebf8efc92f57237038
Author: Guillem Jover 
AuthorDate: Sun Aug 16 22:47:27 2020 +0200

libdpkg: Fix memory leak in filesystem treewalk node free function

Warned-by: gcc ASAN
Stable-Candidate: 1.19.x
---
 lib/dpkg/treewalk.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/dpkg/treewalk.c b/lib/dpkg/treewalk.c
index dee072f2d..3277f3131 100644
--- a/lib/dpkg/treewalk.c
+++ b/lib/dpkg/treewalk.c
@@ -274,6 +274,7 @@ static void
 treenode_free_node(struct treenode *node)
 {
free(node->pathname);
+   free(node->stat);
free(node);
 }
 

-- 
Dpkg.Org's dpkg



[dpkg] 08/68: build: Do not try to use on GNU/Linux

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=631b7591c79395465ad6cb6b959b1dcc3b21971b

commit 631b7591c79395465ad6cb6b959b1dcc3b21971b
Author: Guillem Jover 
AuthorDate: Sun Nov 15 03:26:50 2020 +0100

build: Do not try to use  on GNU/Linux

The glibc project has deprecated this header for some time and made it
emit warnings, and removed it in 2.32. The Linux kernel has removed the
functionality behind the syscall in 5.5.

Warned-by: cpp
---
 configure.ac | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 5ca23b4cc..10d2ad278 100644
--- a/configure.ac
+++ b/configure.ac
@@ -111,13 +111,24 @@ AC_CHECK_HEADERS([\
   kvm.h \
   sys/sysmacros.h \
   sys/param.h \
-  sys/sysctl.h \
   sys/syscall.h \
   sys/user.h \
   sys/procfs.h \
   sys/pstat.h \
   linux/fiemap.h \
 ])
+AS_CASE([$host_os],
+  [linux-gnu*], [
+# The glibc project has deprecated the  header and emits
+# warnings on its usage, and removed it in 2.32. The Linux kernel removed
+# support for it in 5.5.
+  ], [
+# On other systems, we need to check whether to use it.
+AC_CHECK_HEADERS([\
+  sys/sysctl.h \
+])
+  ]
+)
 AC_CHECK_HEADERS([sys/proc.h], [], [], [
 #ifdef HAVE_SYS_PARAM_H
 #include 

-- 
Dpkg.Org's dpkg



[dpkg] 49/68: libdpkg: Fix typo in comment

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=96005ddd9e0ef85b160594263d1dc7e059ab4ee5

commit 96005ddd9e0ef85b160594263d1dc7e059ab4ee5
Author: Guillem Jover 
AuthorDate: Fri Nov 13 21:00:44 2020 +0100

libdpkg: Fix typo in comment

Changelog: silent
---
 lib/dpkg/parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index 7a1f52e8c..c4e5cf21c 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -184,7 +184,7 @@ pkg_parse_verify(struct parsedb_state *ps,
   if ((ps->flags & pdb_recordavailable) ||
   pkg->status > PKG_STAT_HALFINSTALLED) {
 /* We always want usable architecture information (as long as the package
- * is in such a state that it make sense), so that it can be used safely
+ * is in such a state that it makes sense), so that it can be used safely
  * on string comparisons and the like. */
 if (pkgbin->arch->type == DPKG_ARCH_NONE)
   parse_warn(ps, _("missing '%s' field"), "Architecture");

-- 
Dpkg.Org's dpkg



[dpkg] 41/68: dpkg-architecture: Add a --print-format option

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=7c54fa2b232e2d9f9008aeaaa0dd94a810921282

commit 7c54fa2b232e2d9f9008aeaaa0dd94a810921282
Author: Guillem Jover 
AuthorDate: Fri Sep 4 01:02:24 2020 +0200

dpkg-architecture: Add a --print-format option

This makes possible to select the output format for the --print-set and
--print-unset commands. The current values supported are “shell” which
is the current default, and “make”.

Prompted-by: #968963
---
 man/dpkg-architecture.pod|  7 ++-
 scripts/dpkg-architecture.pl | 30 ++
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/man/dpkg-architecture.pod b/man/dpkg-architecture.pod
index 9a4db88fd..02ebfe018 100644
--- a/man/dpkg-architecture.pod
+++ b/man/dpkg-architecture.pod
@@ -82,7 +82,7 @@ Print the value of a single variable.
 =item B<-s>, B<--print-set>
 
 Print an export command. This can be used to set the environment variables
-using the POSIX shell B.
+using the POSIX shell or make B, depending on the output format.
 
 =item B<-u>, B<--print-unset>
 
@@ -145,6 +145,11 @@ specified CPU bits (since dpkg 1.17.14). Either B<32> or 
B<64>.
 Restrict the architectures listed by B<--list-known> to ones with the
 specified endianness (since dpkg 1.17.14). Either B or B.
 
+=item B<--print-format> I
+
+Sets the output format for B<--print-set> and B<--print-unset>
+(since dpkg 1.20.6), to either B (default) or B.
+
 =item B<-f>, B<--force>
 
 Values set by existing environment variables with the same name as used by
diff --git a/scripts/dpkg-architecture.pl b/scripts/dpkg-architecture.pl
index 847ea0519..6776117de 100755
--- a/scripts/dpkg-architecture.pl
+++ b/scripts/dpkg-architecture.pl
@@ -66,6 +66,9 @@ sub usage {
 restrict architecture list matching .
   -E, --match-endian 
 restrict architecture list matching .
+  --print-format 
+use  for --print-set and --print-unset,
+  allowed values: shell (default), make.
   -f, --force   force flag (override variables set in 
environment).')
 . "\n", $Dpkg::PROGNAME;
 }
@@ -153,6 +156,9 @@ my %arch_vars = (
 DEB_TARGET_GNU_TYPE => DEB_TARGET | DEB_GNU_INFO,
 );
 
+my %known_print_format = map { $_ => 1 } qw(shell make);
+my $print_format = 'shell';
+
 my $req_vars = DEB_ALL;
 my $req_host_arch = '';
 my $req_host_gnu_type = '';
@@ -207,6 +213,10 @@ while (@ARGV) {
 } elsif ($arg eq '-s' or $arg eq '--print-set') {
$req_vars = DEB_ALL;
$action = 'print-set';
+} elsif ($arg eq '--print-format') {
+$print_format = shift;
+error(g_('%s is not a supported print format'), $print_format)
+unless exists $known_print_format{$print_format};
 } elsif ($arg eq '-f' or $arg eq '--force') {
 $force=1;
 } elsif ($arg eq '-q' or $arg eq '--query') {
@@ -332,12 +342,24 @@ if ($action eq 'list') {
print "$k=$v{$k}\n";
 }
 } elsif ($action eq 'print-set') {
-foreach my $k (sort keys %arch_vars) {
-   print "$k=$v{$k}; ";
+if ($print_format eq 'shell') {
+foreach my $k (sort keys %arch_vars) {
+print "$k=$v{$k}; ";
+}
+print 'export ' . join(' ', sort keys %arch_vars) . "\n";
+} elsif ($print_format eq 'make') {
+foreach my $k (sort keys %arch_vars) {
+print "export $k = $v{$k}\n";
+}
 }
-print 'export ' . join(' ', sort keys %arch_vars) . "\n";
 } elsif ($action eq 'print-unset') {
-print 'unset ' . join(' ', sort keys %arch_vars) . "\n";
+if ($print_format eq 'shell') {
+print 'unset ' . join(' ', sort keys %arch_vars) . "\n";
+} elsif ($print_format eq 'make') {
+foreach my $k (sort keys %arch_vars) {
+print "undefine $k\n";
+}
+}
 } elsif ($action eq 'equal') {
 exit !debarch_eq($v{DEB_HOST_ARCH}, $req_eq_arch);
 } elsif ($action eq 'is') {

-- 
Dpkg.Org's dpkg



[dpkg] 32/68: libdpkg: Fix single-instance memory leak with fsys dir

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=f13aebc8a05da51a54da55d55b023ca8199a6471

commit f13aebc8a05da51a54da55d55b023ca8199a6471
Author: Guillem Jover 
AuthorDate: Tue Aug 18 01:36:00 2020 +0200

libdpkg: Fix single-instance memory leak with fsys dir

This variable is usually set up once at the beginning of the execution
and then never changed again.

Warned-by: gcc ASAN
---
 lib/dpkg/fsys-dir.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/lib/dpkg/fsys-dir.c b/lib/dpkg/fsys-dir.c
index 15335b23e..40ccb7fe8 100644
--- a/lib/dpkg/fsys-dir.c
+++ b/lib/dpkg/fsys-dir.c
@@ -29,6 +29,7 @@
 #include 
 
 static const char *fsys_dir = "";
+static char *fsys_dir_alloc;
 
 /**
  * Set current on-disk filesystem root directory.
@@ -45,22 +46,23 @@ static const char *fsys_dir = "";
 const char *
 dpkg_fsys_set_dir(const char *dir)
 {
-   char *new_dir;
-
if (dir == NULL) {
const char *env;
 
env = getenv("DPKG_ROOT");
if (env)
dir = env;
-   else
-   dir = "";
}
 
-   new_dir = m_strdup(dir);
-   path_trim_slash_slashdot(new_dir);
+   free(fsys_dir_alloc);
 
-   fsys_dir = new_dir;
+   if (dir == NULL) {
+   fsys_dir = "";
+   fsys_dir_alloc = NULL;
+   } else {
+   fsys_dir = fsys_dir_alloc = m_strdup(dir);
+   path_trim_slash_slashdot(fsys_dir_alloc);
+   }
 
return fsys_dir;
 }

-- 
Dpkg.Org's dpkg



[dpkg] 54/68: u-a: Fix short-lived memory leaks for alternative structs

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=55700d23274a6487f5f91b43074b9027be1371d4

commit 55700d23274a6487f5f91b43074b9027be1371d4
Author: Guillem Jover 
AuthorDate: Tue Aug 25 01:13:12 2020 +0200

u-a: Fix short-lived memory leaks for alternative structs

Warned-by: gcc ASAN
---
 utils/update-alternatives.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index fd4146d11..569aca4ab 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -1484,6 +1484,7 @@ alternative_load(struct alternative *a, enum altdb_flags 
flags)
syserr(_("cannot stat file '%s'"), ctx.filename);
if (st.st_size == 0) {
altdb_context_free(&ctx);
+   alternative_reset(a);
return false;
}
 
@@ -3061,6 +3062,7 @@ main(int argc, char **argv)
 * link group file. */
if (!alternative_load(a, ALTDB_WARN_PARSER)) {
verbose(_("no alternatives for %s"), a->master_name);
+   alternative_free(a);
exit(0);
}
} else if (action == ACTION_INSTALL) {
@@ -3104,6 +3106,7 @@ main(int argc, char **argv)
/* Alternative already exists, check if anything got
 * updated. */
alternative_evolve(a, inst_alt, current_choice, 
fileset);
+   alternative_free(inst_alt);
} else {
/* Alternative doesn't exist, create from parameters. */
alternative_free(a);
@@ -3123,5 +3126,8 @@ main(int argc, char **argv)
if (modifies_alt)
alternative_update(a, current_choice, new_choice);
 
+   if (a)
+   alternative_free(a);
+
return 0;
 }

-- 
Dpkg.Org's dpkg



[dpkg] 52/68: u-a: Fix memory leaks for alternative database context on load errors

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=2096f4fe23ce48e5f40d4d6234f502b2e61d50d1

commit 2096f4fe23ce48e5f40d4d6234f502b2e61d50d1
Author: Guillem Jover 
AuthorDate: Tue Aug 25 01:13:12 2020 +0200

u-a: Fix memory leaks for alternative database context on load errors

Warned-by: gcc ASAN
---
 utils/update-alternatives.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index b98fbe1a6..0aeec5ad2 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -1465,8 +1465,10 @@ alternative_load(struct alternative *a, enum altdb_flags 
flags)
/* Open the alternative file. */
ctx.fh = fopen(ctx.filename, "r");
if (ctx.fh == NULL) {
-   if (errno == ENOENT)
+   if (errno == ENOENT) {
+   altdb_context_free(&ctx);
return false;
+   }
 
syserr(_("unable to open file '%s'"), ctx.filename);
}
@@ -1480,8 +1482,10 @@ alternative_load(struct alternative *a, enum altdb_flags 
flags)
/* Verify the alternative is not empty. */
if (fstat(fileno(ctx.fh), &st) == -1)
syserr(_("cannot stat file '%s'"), ctx.filename);
-   if (st.st_size == 0)
+   if (st.st_size == 0) {
+   altdb_context_free(&ctx);
return false;
+   }
 
/* Start parsing mandatory attributes (link+status) of the alternative 
*/
alternative_reset(a);

-- 
Dpkg.Org's dpkg



[dpkg] 34/68: libdpkg: Reset error context errmsg after free()

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=889848ed58a6c496ab130647cce8dd0bcd53aaaf

commit 889848ed58a6c496ab130647cce8dd0bcd53aaaf
Author: Guillem Jover 
AuthorDate: Tue Aug 18 01:27:39 2020 +0200

libdpkg: Reset error context errmsg after free()

This makes sure we are never going to doubly free it.

Warned-by: gcc ASAN
Stable-Candidate: 1.19.x
---
 lib/dpkg/ehandle.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index bfa220908..be95c3642 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -173,6 +173,7 @@ error_context_errmsg_free(struct error_context *ec)
 {
   if (ec->errmsg != emergency.errmsg)
 free(ec->errmsg);
+  ec->errmsg = NULL;
 }
 
 static void

-- 
Dpkg.Org's dpkg



[dpkg] 47/68: libdpkg: Ignore not-installed packages for source related virtual fields

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=536a38582a2d92da84f82d850e22f581b00d2082

commit 536a38582a2d92da84f82d850e22f581b00d2082
Author: Guillem Jover 
AuthorDate: Mon Nov 2 09:46:58 2020 +0100

libdpkg: Ignore not-installed packages for source related virtual fields

The source name and source versions are not available for not-installed
packages, so we should not try to print anything as that will end up
being bogus, or produce parsing problems for version related virtual
fields.

Closes: #972580
---
 lib/dpkg/pkg-format.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/lib/dpkg/pkg-format.c b/lib/dpkg/pkg-format.c
index 07474a211..8af7c4fe3 100644
--- a/lib/dpkg/pkg-format.c
+++ b/lib/dpkg/pkg-format.c
@@ -333,6 +333,9 @@ virt_source_package(struct varbuf *vb,
const char *name;
size_t len;
 
+   if (pkg->status == PKG_STAT_NOTINSTALLED)
+   return;
+
name = pkgbin->source;
if (name == NULL)
name = pkg->set->name;
@@ -347,6 +350,9 @@ virt_source_version(struct varbuf *vb,
 const struct pkginfo *pkg, const struct pkgbin *pkgbin,
 enum fwriteflags flags, const struct fieldinfo *fip)
 {
+   if (pkg->status == PKG_STAT_NOTINSTALLED)
+   return;
+
varbuf_add_source_version(vb, pkg, pkgbin);
 }
 
@@ -357,6 +363,9 @@ virt_source_upstream_version(struct varbuf *vb,
 {
struct dpkg_version version;
 
+   if (pkg->status == PKG_STAT_NOTINSTALLED)
+   return;
+
pkg_source_version(&version, pkg, pkgbin);
 
varbuf_add_str(vb, version.version);

-- 
Dpkg.Org's dpkg



[dpkg] 46/68: libdpkg: Check that the ar archive time is within bounds

2020-11-22 Thread Guillem Jover
This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=b885b73443f8af8ad0cad4c10a35e5511448b020

commit b885b73443f8af8ad0cad4c10a35e5511448b020
Author: Guillem Jover 
AuthorDate: Fri Aug 28 01:01:34 2020 +0200

libdpkg: Check that the ar archive time is within bounds
---
 lib/dpkg/ar.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/dpkg/ar.c b/lib/dpkg/ar.c
index 57d304ce8..6eea5ad13 100644
--- a/lib/dpkg/ar.c
+++ b/lib/dpkg/ar.c
@@ -172,6 +172,8 @@ dpkg_ar_member_put_header(struct dpkg_ar *ar, struct 
dpkg_ar_member *member)
ohshit(_("ar member name '%s' length too long"), member->name);
if (member->size > 99L)
ohshit(_("ar member size %jd too large"), 
(intmax_t)member->size);
+   if (member->time > L)
+   ohshit(_("ar member time %jd too large"), 
(intmax_t)member->time);
 
n = snprintf(header, sizeof(struct dpkg_ar_hdr) + 1,
 "%-16s%-12jd%-6lu%-6lu%-8lo%-10jd`\n",

-- 
Dpkg.Org's dpkg