[XEN PATCH] xen: fix unspecified behavior in tr invocation

Nicola Vetrini posted 1 patch 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/df5119a0e5f617ed1a2756dfca77368596e2c369.1750949938.git.nicola.vetrini@bugseng.com
xen/scripts/Makefile.asm-generic | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[XEN PATCH] xen: fix unspecified behavior in tr invocation
Posted by Nicola Vetrini 4 months ago
The result of the command is undefined according to the specification if
the "string2" argument in tr is shorter than "string1". GNU tr behaves
correctly by extending "string2" to repeat the last character.

Fixes: eb61a4fb14d2 ("xen: fix header guard generation for asm-generic headers")
Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
 xen/scripts/Makefile.asm-generic | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/scripts/Makefile.asm-generic b/xen/scripts/Makefile.asm-generic
index f6850758c54b..4e628e116adf 100644
--- a/xen/scripts/Makefile.asm-generic
+++ b/xen/scripts/Makefile.asm-generic
@@ -34,7 +34,7 @@ unwanted    := $(filter-out $(generic-y) $(generated-y),$(old-headers))
 quiet_cmd_wrap = WRAP    $@
       cmd_wrap = \
 	arch=$$(echo $@ | sed -n 's:.*arch/\([^/]*\)/.*:\1:p' | tr a-z A-Z); \
-	upper=$$(echo $*.h | tr a-z A-Z | tr '/.-' '__'); \
+	upper=$$(echo $*.h | tr a-z A-Z | tr '/.-' '___'); \
 	echo "\#ifndef $${arch}_GENERIC_$${upper}" > $@.new; \
 	echo "\#define $${arch}_GENERIC_$${upper}" >> $@.new; \
 	echo "\#include <asm-generic/$*.h>" >> $@.new; \
-- 
2.43.0
Re: [XEN PATCH] xen: fix unspecified behavior in tr invocation
Posted by Jan Beulich 4 months ago
On 26.06.2025 16:59, Nicola Vetrini wrote:
> The result of the command is undefined according to the specification if
> the "string2" argument in tr is shorter than "string1". GNU tr behaves
> correctly by extending "string2" to repeat the last character.
> 
> Fixes: eb61a4fb14d2 ("xen: fix header guard generation for asm-generic headers")
> Reported-by: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>