From patchwork Mon Apr 11 02:24:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: antlers X-Patchwork-Id: 38511 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B780127BBEA; Mon, 11 Apr 2022 03:25:40 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 5585727BBE9 for ; Mon, 11 Apr 2022 03:25:40 +0100 (BST) Received: from localhost ([::1]:54948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ndjkJ-0005p5-Bq for patchwork@mira.cbaines.net; Sun, 10 Apr 2022 22:25:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ndjk7-0005oO-Bg for guix-patches@gnu.org; Sun, 10 Apr 2022 22:25:27 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48127) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ndjjj-0000oe-0F for guix-patches@gnu.org; Sun, 10 Apr 2022 22:25:26 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ndjji-0005Tv-R1 for guix-patches@gnu.org; Sun, 10 Apr 2022 22:25:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54846] [PATCH] gnu: linux: Escape the values of string-type kconfig options Resent-From: antlers Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 11 Apr 2022 02:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 54846 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54846@debbugs.gnu.org Cc: antlers X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164964389121049 (code B ref -1); Mon, 11 Apr 2022 02:25:02 +0000 Received: (at submit) by debbugs.gnu.org; 11 Apr 2022 02:24:51 +0000 Received: from localhost ([127.0.0.1]:42024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndjjX-0005TR-HG for submit@debbugs.gnu.org; Sun, 10 Apr 2022 22:24:51 -0400 Received: from lists.gnu.org ([209.51.188.17]:42452) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndjjV-0005TJ-PG for submit@debbugs.gnu.org; Sun, 10 Apr 2022 22:24:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ndjjV-0005iF-E5 for guix-patches@gnu.org; Sun, 10 Apr 2022 22:24:49 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:52151) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ndjjT-0000ji-Qd for guix-patches@gnu.org; Sun, 10 Apr 2022 22:24:49 -0400 Received: by mail-pj1-x1034.google.com with SMTP id bg24so1441717pjb.1 for ; Sun, 10 Apr 2022 19:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Oom+QP5LNVAGwFpKdZ0H6N8Ai8LljNt2dQbzziiAxwQ=; b=FbljAGSFV6xdroZB2Xoi5M+cq/k+JjGKNN0YO4gf1rMx1zydQWoptBlFZZu5XYjrwD s0ce71YBcv43FXHHRL6fsNLbNjm97dhfP8JqPUfvQJgf3fDxMpVSi4KsNXUNGCp+zhal uggxDMMjMQeM03iZyMRpAt47X3oiKCSQCO9rgsShdo9DU+gr9ph6rRRGXOn6ePK/3mQe Dfgd6ELJE7Z1lOT0FdyXg7kN7T7zUnAAVW1huUG94X2M+6C/5jyVXuzcUZuim6EAuBp6 fOVuYu72nP/t4Ssts3gfcBM/9ofQNuRF24R6k6IT+y0SSgEW1CfzIdl/38edx9PBpLd2 dF/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Oom+QP5LNVAGwFpKdZ0H6N8Ai8LljNt2dQbzziiAxwQ=; b=aC5xY006V/cRMtcNrX9BIyuRIq5DLTDbp6fvGpr6WRIeZUYGaiQ0kl/g1nZeWNrCW1 Skvl/xJ+udfJgsH4PvrhPJ3Jgh7nGQg0N9ahLClxsELmwxKZrTzy6+Cu7ZiqbXL6d9DC mamO2N/a5wQml0FfmjYPNnpKUQRFMN7dbiSkv1vGQ9Ql1/rBAODJfZR7lV9JxG9bsJCI MSMxRC0tlPSueQ7xXzNLxT4FqgZs2jRVOwiJC63NGlmB++dIOSRE0ueFriEUGyv/jOdR dppkMbDWPfwNeOUnFwTVv78QLzpoVPl+1AIvSbQCaLVAiB1nAyPPuzVhy/bWSYBrjyXq kucw== X-Gm-Message-State: AOAM532x1B1+IOspNt/gzVODZdVr4jXmodpflDqcpag3MyzU4xoHny98 PXRwyPHI90V7yw77Ab/nkmouPwVC73cN2A== X-Google-Smtp-Source: ABdhPJx+jzrG/4N1QYZIFS6GMQQEzLSnAr15DR+ytdgxeISZrkANuAVTHBkVCdBUjqUrk1EwhCSMzw== X-Received: by 2002:a17:90a:4403:b0:1ca:a4a3:6824 with SMTP id s3-20020a17090a440300b001caa4a36824mr33907973pjg.20.1649643866267; Sun, 10 Apr 2022 19:24:26 -0700 (PDT) Received: from tower.hitronhub.home (24-113-171-200.wavecable.com. [24.113.171.200]) by smtp.gmail.com with ESMTPSA id k62-20020a17090a4cc400b001c7ea7f487asm18774475pjh.39.2022.04.10.19.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Apr 2022 19:24:25 -0700 (PDT) From: antlers Date: Sun, 10 Apr 2022 19:24:10 -0700 Message-Id: <20220411022410.5606-1-autumnalantlers@gmail.com> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=autumnalantlers@gmail.com; helo=mail-pj1-x1034.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/linux.scm (config->string): add escape-string Handles characters within the set (char-set-intersection char-set:ascii char-set:printing), removing those which are known to be unsupported. --- gnu/packages/linux.scm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index b31fe0a580..60ae668fd9 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -761,6 +761,22 @@ (define %bpf-extra-linux-options ("CONFIG_IKHEADERS" . #t))) (define (config->string options) + (define (escape-string str) + "Returns STR with the escapes necessary to be read as a string-type + option's value. Handles characters within the set (char-set-intersection + char-set:ascii char-set:printing), removing those which are known to be + unsupported." + (fold (match-lambda* (((match? fmt) str) + (transform-string str match? + (cut format #f fmt <>)))) + str + `((#\# "") ; No known way to escape # characters. + (#\$ "$~a") + ("\"\\'`" "\\~a") + (";:()#" "\\\\~a") + ("|" "\\\\\\~a") + ;; No support for tabs, newlines, etc. + (,(char-set->string (ucs-range->char-set 9 14)) "")))) (string-join (map (match-lambda ((option . 'm) (string-append option "=m")) @@ -769,7 +785,9 @@ (define (config->string options) ((option . #f) (string-append option "=n")) ((option . string) - (string-append option "=\"" string "\""))) + (string-append option "=\"" + (escape-string string) + "\""))) options) "\n"))