* update less to 1:643-2

This commit is contained in:
Alexander Baldeck 2024-05-14 21:49:49 +02:00
parent e46a63d3b5
commit 4b5efd3cbf
2 changed files with 76 additions and 4 deletions

View File

@ -5,18 +5,20 @@
pkgname=less
pkgver=643
pkgrel=1
pkgrel=2
epoch=1
pkgdesc='A terminal based program for viewing text files'
license=('GPL3')
license=('GPL-3.0-or-later')
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
url='https://www.greenwoodsoftware.com/less/'
depends=('glibc' 'ncurses' 'pcre2')
validpgpkeys=('AE27252BD6846E7D6EAE1DD6F153A7C833235259') # Mark Nudelman
source=("https://www.greenwoodsoftware.com/$pkgname/$pkgname-$pkgver.tar.gz"
"$pkgname-$pkgver.tar.gz.sig::https://www.greenwoodsoftware.com/$pkgname/$pkgname-$pkgver.sig")
"$pkgname-$pkgver.tar.gz.sig::https://www.greenwoodsoftware.com/$pkgname/$pkgname-$pkgver.sig"
"backport-007521ac3c95bc76.patch")
sha256sums=('2911b5432c836fa084c8a2e68f6cd6312372c026a58faaa98862731c8b6052e8'
'SKIP')
'SKIP'
'2fb1552faecfd9956966819e19ef699a20370596f4f04370ac19fee60e1bd412')
prepare() {
cd $pkgname-$pkgver
@ -27,6 +29,9 @@ prepare() {
src="${src##*/}"
[[ $src = *.patch ]] || continue
echo "Applying patch $src..."
# https://www.openwall.com/lists/oss-security/2024/04/12/5
# https://github.com/gwsw/less/commit/007521ac3c95bc76.patch
# backport by tpowa@archlinux.org for less-643
patch -Np1 < "../$src"
done
}

View File

@ -0,0 +1,67 @@
From 007521ac3c95bc76e3d59c6dbfe75d06c8075c33 Mon Sep 17 00:00:00 2001
From: Mark Nudelman <markn@greenwoodsoftware.com>
Date: Thu, 11 Apr 2024 17:49:48 -0700
Subject: [PATCH] Fix bug when viewing a file whose name contains a newline.
---
filename.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/filename.c b/filename.c
index f90e0e82..a52c6354 100644
--- a/filename.c
+++ b/filename.c
@@ -133,6 +133,15 @@ static constant char * metachars(void)
return (strchr(metachars(), c) != NULL);
}
+/*
+ * Must use quotes rather than escape char for this metachar?
+ */
+static int must_quote(char c)
+{
+ /* {{ Maybe the set of must_quote chars should be configurable? }} */
+ return (c == '\n');
+}
+
/*
* Insert a backslash before each metacharacter in a string.
*/
@@ -164,6 +173,9 @@ public char * shell_quoten(constant char *s, size_t slen)
* doesn't support escape chars. Use quotes.
*/
use_quotes = 1;
+ } else if (must_quote(*p))
+ {
+ len += 3; /* open quote + char + close quote */
} else
{
/*
@@ -193,15 +205,22 @@ public char * shell_quoten(constant char *s, size_t slen)
{
while (*s != '\0')
{
- if (metachar(*s))
+ if (!metachar(*s))
{
- /*
- * Add the escape char.
- */
+ *p++ = *s++;
+ } else if (must_quote(*s))
+ {
+ /* Surround the char with quotes. */
+ *p++ = openquote;
+ *p++ = *s++;
+ *p++ = closequote;
+ } else
+ {
+ /* Insert an escape char before the char. */
strcpy(p, esc);
p += esclen;
+ *p++ = *s++;
}
- *p++ = *s++;
}
*p = '\0';
}