Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1muL76-0002e5-A6 for mharc-grub-devel@gnu.org; Mon, 06 Dec 2021 16:01:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muL75-0002bW-2v for grub-devel@gnu.org; Mon, 06 Dec 2021 16:01:31 -0500 Received: from mout.gmx.net ([212.227.17.21]:53719) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muL72-0005Hw-FN for grub-devel@gnu.org; Mon, 06 Dec 2021 16:01:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1638824484; bh=KvC4eSpcCdf+/Yv3Qiyg4H8hRLUUsoDFwvWfOv5//XA=; h=X-UI-Sender-Class:Date:Subject:To:References:From:In-Reply-To; b=aobz0PHOpS2zt8RPkFkUcmJfoXl9VlQ1c96Wur7kRrgmRDXnOD2fQ98eW5IEIFI1I c1CN1/PDrddhBjlmlRnGIT6kQMiPCtfl9JLZtQP2PYZ0qBnsVquMcwXKh+kIqqJAUD 8ZlXUMEdrA2PfGz21IeUUtPjrx74+i8kOZ5ITenA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.23] ([79.195.95.75]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MSKy8-1n0pMx3VCS-00SdGe; Mon, 06 Dec 2021 22:01:23 +0100 Message-ID: <9af6034e-e8f4-5fbf-babf-fa4cd9988695@gmx.de> Date: Mon, 6 Dec 2021 22:01:22 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH v2] misc: Allow selective disabling of debug facility names Content-Language: de-DE To: Glenn Washburn , Daniel Kiper , grub-devel@gnu.org References: <20211206170312.811318-1-development@efficientek.com> From: Michael Schierl In-Reply-To: <20211206170312.811318-1-development@efficientek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:MtFhitefvnQy+gT7bOJUmd+2bUFbR1hJGvlBodsSH64ydlE/xUp pr9ZbWfcdF8FKXcpTY9byzKSUMNw+NLQENp0GOTj5COGsZzJ/7dgMhrlmALCKElV8qOnTn1 FpZolDReujXGf7mKR8gHgznm7Oy9CKNN6ZngGVkBGR3+tXG+IgFHqMyTp9xiF0qdJjwzGmE q2hAxx2+UCyxYLEDAvL0w== X-UI-Out-Filterresults: notjunk:1;V03:K0:8XDeEGmWrZk=:BetD5n75bPT3yveSMTJCIS sAkW47OFavuZg3cNg5oKeL3Q3Wceu54WNp0bq91oRiekAId3pfRBPoa5gmUkPullRIXKs7YFJ 4Od0rsmavAqb5Tj6wnYsXuAfBYB9CMfO7CJDfUNm8CSRPABVGsvuOZbTQg4OUtoogY36RLDUD D6jnNoWX0JoJRFrwBcBpucjU38WUqCm+N7T9QS8u18l2d61kY3SVerQHTZgKuWlzLXif+zCQO gYjBBVdEQ4+UJZ8IY9FrIzLHDBZpEv5JuVGbs+YWuWK9uB4ZUgnyIDsA1B2n/G3pon4KxVuwK /5JdvY+H99/Yep7EkdDxTfCHfjYa1WkK1At76NelUo0lGBAuPWTgsyKtml2A73aMMZX9uqDfx ZaSba0aDt0RZnkvSt/PQJ5KiCHpNRb4750k5OYiVxYulHA2qnunF23LTiejEIkD/uLyUKq+jj 02sD6gx1AHF9GsR+wCTco0C5QmdEwIKd0LK9WOiG49eTGTBIa1lTpcWQHTb7mKyn+0+LKpqrU ThvXsxJ5B96Q00beNbPFTzuyDzBn8sA5Bv47hhoZiyf72a23Hu3MpLl/B+A05U3zvebSjSZl0 pFvvhe/nk8FxpIaHXAm1deAweuvF0kZaYiA0zghTFEPNnCW1VVBqGH17VCufnV+u/EPO54Q5w MVD6RFbtyHApftcBA02mX2p6iVXhrBndKJBex1kO4uNJ2KVebQWbRddE+gv33WNJYM9rxpdJB KT8jpslcRo3SRvI93VatdsooajNVDRxRDdIkFIRFpBdomtjci7guThL/yPQB47RJFPPRWY+F/ KwfZnpJ7o4omgoOzu6NESi+ctsgAvFarpzt7KdSrgdTXZxDhAClVqdgMsdHwGThVETE525Omu oAKTmETDpa6g3K4jn/GT5IkRKffDyunm8dCBX5G4TbZb2nDDW7uX+P6f4NZYrxzspxJOBk94r jWEsExd9E/07eh6DMIyAev0WMUCi0TBv5huLeBtdkx6Q1hXCZCLlVMENDiUlDlIrQUUrQeGtz Yql+j1gaZJxS3/W8kE5jJqvgP3/PPOp03sN1ab7TbVTjElSFrHUW/HYEGX7bvpr5QPQjqbdFH 9F6XiQ0YG7MnRE= Received-SPF: pass client-ip=212.227.17.21; envelope-from=schierlm@gmx.de; helo=mout.gmx.net X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, NICE_REPLY_A=-2.076, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Dec 2021 21:01:31 -0000 Hello Glenn, Comments below, note that I did not test the patch so maybe I am missing something. Am 06.12.2021 um 18:03 schrieb Glenn Washburn: > grub_debug_enabled (const char * condition) > { > - const char *debug; > + const char *debug, *found; > + grub_size_t clen; > + int ret =3D 0; > > debug =3D grub_env_get ("debug"); > if (!debug) > return 0; > > - if (grub_strword (debug, "all") || grub_strword (debug, condition)) > - return 1; > + if (grub_strword (debug, "all")) > + { > + ret =3D 1; > + if (debug[3] =3D=3D '\0') > + return 1; maybe move the conditional before the assignment of ret? > + } > > - return 0; > + clen =3D grub_strlen (condition); > + found =3D debug; > + while(1) > + { > + found =3D grub_strstr (found+1, condition); Off by one error: in case the condition is the first one in debug, it won't be found. And after fixing this... > + > + if (found =3D=3D NULL) > + break; > + > + /* Found condition is not a whole word, so ignore it */ > + if (*(found + clen) !=3D '\0' && *(found + clen) !=3D ',' > + && !grub_isspace (*(found + clen))) > + continue; > + > + /* > + * If found condition is prefixed with '-' and the start is on a = word > + * boundary, then disable debug. Otherwise, if the start is on a = word > + * boundary, enable debug. If neither, ignore. > + */ > + if (*(found-1) =3D=3D '-' && ((found =3D=3D debug + 1) || (*(foun= d-2) =3D=3D ',' > + || grub_isspace (*(found-2))))) you will read beyond the start of the string here. > + ret =3D 0; > + else if (*(found-1) =3D=3D ',' || grub_isspace (*(found-1))) What about the other separators in grub_iswordseparator besides comma? Regards, Michael