Subject: [PATCH] scripts: package: Disable searching with the empty string

From: Richard Sent <[email-masked]>
Date: Fri, 5 Apr 2024 21:05:53 -0400

Reported in <https://issues.guix.gnu.org/70223>.

* guix/scripts/package.scm (process-query): search operating no longer passes
empty strings to make-regexp to avoid unbounded memory usage.

Change-Id: I8194591f0428c4f88fb101c0226b98f593a55709
---
Hi Guix!

Not sure of the usefulness of small patches like this, but figure it
gives me an excuse to trawl the repo and it's better to send it and
not be needed than the inverse.

I considered adding a --force flag to forcefully allow "" searches,
but since multiple scripts use package.scm and there's a lot of CLI
flags already it didn't seem appropriate to add another one,
particularly if it just results in a system freeze.

 guix/scripts/package.scm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index a489e06e73..66e5384ddc 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -891,6 +891,8 @@ (define (process-query opts)
 
       (('search _)
        (let* ((patterns (filter-map (match-lambda
+                                      ;; https://issues.guix.gnu.org/70223
+                                      (('query 'search "") #f)
                                       (('query 'search rx) rx)
                                       (_                   #f))
                                     opts))

base-commit: 886ed061d7c57eb9d707b2af2c87402b86becf70
-- 
2.41.0