[pacman-dev,v2] pacman: correct length of ".files.sig" string

Message ID 20210121024958.55109-1-pacman-dev@hardfalcon.net
State New
Headers show
Series [pacman-dev,v2] pacman: correct length of ".files.sig" string | expand

Commit Message

Pascal Ernster Jan. 21, 2021, 2:49 a.m. UTC
Running "pacman -Sc" deletes /var/lib/pacman/sync/*.files.sig due to a
wrong string length being used when checking filename suffixes in that
directory. In turn, these missing signature files cause both the
corresponding "*.files" files and their signatures being forcibly
re-downloaded again when "pacman -Sy" is executed.

Since official Archlinux repos don't use signed database files yet, this
only affects people who use custom repos with signed database files, for
which they have set the "SigLevel" directive to "Required" or
"DatabaseRequired" in /etc/pacman.conf.

Fixes FS#66472

Signed-off-by: Pascal Ernster <pacman-dev@hardfalcon.net>
---
 src/pacman/sync.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Anatol Pomozov Jan. 21, 2021, 3:22 a.m. UTC | #1
Hi

On Wed, Jan 20, 2021 at 6:50 PM Pascal Ernster
<pacman-dev@hardfalcon.net> wrote:
>
> Running "pacman -Sc" deletes /var/lib/pacman/sync/*.files.sig due to a
> wrong string length being used when checking filename suffixes in that
> directory. In turn, these missing signature files cause both the
> corresponding "*.files" files and their signatures being forcibly
> re-downloaded again when "pacman -Sy" is executed.
>
> Since official Archlinux repos don't use signed database files yet, this
> only affects people who use custom repos with signed database files, for
> which they have set the "SigLevel" directive to "Required" or
> "DatabaseRequired" in /etc/pacman.conf.
>
> Fixes FS#66472
>
> Signed-off-by: Pascal Ernster <pacman-dev@hardfalcon.net>
> ---
>  src/pacman/sync.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/pacman/sync.c b/src/pacman/sync.c
> index a05af5da..9ec4c92e 100644
> --- a/src/pacman/sync.c
> +++ b/src/pacman/sync.c
> @@ -105,7 +105,7 @@ static int sync_cleandb(const char *dbpath)
>                         dbname = strndup(dname, len - 7);
>                 } else if(len > 6 && strcmp(dname + len - 6, ".files") == 0) {
>                         dbname = strndup(dname, len - 6);
> -               } else if(len > 6 && strcmp(dname + len - 6, ".files.sig") == 0) {
> +               } else if(len > 10 && strcmp(dname + len - 10, ".files.sig") == 0) {
>                         dbname = strndup(dname, len - 10);
>                 } else {
>                         ret += unlink_verbose(path, 0);
> --
> 2.30.0

Awesome! The patch looks great to me.

Patch

diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index a05af5da..9ec4c92e 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -105,7 +105,7 @@  static int sync_cleandb(const char *dbpath)
 			dbname = strndup(dname, len - 7);
 		} else if(len > 6 && strcmp(dname + len - 6, ".files") == 0) {
 			dbname = strndup(dname, len - 6);
-		} else if(len > 6 && strcmp(dname + len - 6, ".files.sig") == 0) {
+		} else if(len > 10 && strcmp(dname + len - 10, ".files.sig") == 0) {
 			dbname = strndup(dname, len - 10);
 		} else {
 			ret += unlink_verbose(path, 0);