This commit is contained in:
joborun linux 2024-04-13 14:36:05 +03:00
parent b1c2f1c673
commit ec01afb933
4 changed files with 87 additions and 10 deletions

View File

@ -7,13 +7,14 @@
pkgname=less
pkgver=643
pkgrel=01
pkgrel=02
epoch=1
pkgdesc='A terminal based program for viewing text files'
url='https://www.greenwoodsoftware.com/less/'
depends=('glibc' 'ncurses' 'pcre2')
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")
prepare() {
cd $pkgname-$pkgver
@ -25,6 +26,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
@ -45,11 +49,13 @@ package() {
arch=(x86_64)
license=('GPL3')
license=('GPL-3.0-or-later')
validpgpkeys=('AE27252BD6846E7D6EAE1DD6F153A7C833235259') # Mark Nudelman
sha256sums=(2911b5432c836fa084c8a2e68f6cd6312372c026a58faaa98862731c8b6052e8 # less-643.tar.gz
2aec0393a32dacd44cbd8a57ad21d842739f3262c6e02fa2d28abd105ea5e5cf) # less-643.tar.gz.sig
2aec0393a32dacd44cbd8a57ad21d842739f3262c6e02fa2d28abd105ea5e5cf # less-643.tar.gz.sig
2fb1552faecfd9956966819e19ef699a20370596f4f04370ac19fee60e1bd412) # backport-007521ac3c95bc76.patch
## bc4589582175e9719c8d9bd5689b94152c445f2c52bc4b16ef5cc864eca81c74 less-1:643-02-x86_64.pkg.tar.lz
## 100bcab42390634095d02f8e408079ec063934f75e814f1b8082cbc096c33d43 less-1:643-01-x86_64.pkg.tar.lz

View File

@ -4,18 +4,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')
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
@ -26,6 +28,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';
}

View File

@ -1,3 +1,2 @@