Ticket #3379 (closed defect: fixed)

Opened 9 years ago

Last modified 8 years ago

bashism in /bin/sh script

Reported by: onlyjob Owned by: zaytsev
Priority: minor Milestone: 4.8.16
Component: mc-vfs Version: 4.8.15
Keywords: bashism Cc:
Blocked By: Blocking:
Branch state: no branch Votes for changeset:

Description

As reported in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=772306

Bashism were found in the src/vfs/extfs/helpers/gitfs+ file:

26:    echo -e "$2" > "$4"

Therefore correct functioning of this script is not guaranteed under "/bin/sh".
"echo -e" should be replaced with "printf", see more:

https://wiki.ubuntu.com/DashAsBinSh#echo

Change History

comment:1 Changed 9 years ago by onlyjob

Something like this can fix it:

--- a/src/vfs/extfs/helpers/gitfs+
+++ b/src/vfs/extfs/helpers/gitfs+
@@ -22,9 +22,9 @@
 }
 
 gitfs_copyout()
 {
-    echo -e "$2" > "$4"
+    printf "$2\n" > "$4"
     b=`echo "$prefix"| wc -c`
     b=`expr "$b" + 1`
     # remove prefix from file name
     echo "`dirname "$3"`/`basename "$3" | tail -c+"$b"`" >> "$4"

Alternatively "/bin/echo -e" can be used instead of "echo -e".

comment:2 follow-up: ↓ 3 Changed 9 years ago by ossi

you just committed "printf usage FAILs 101".

printf "%s\n" "$2" > "$4"

comment:3 in reply to: ↑ 2 Changed 9 years ago by egmont

Replying to ossi:

you just committed "printf usage FAILs 101".

So did the original echo command :) in fact, every echo command whose first parameter is untrusted. Both bash's and coreutils's echo recognize certain flags but not "--".

printf %s is indeed the right way to go.

comment:4 Changed 8 years ago by zaytsev

  • Status changed from new to accepted
  • Owner set to zaytsev
  • Version changed from 4.8.13 to 4.8.15
  • Milestone changed from Future Releases to 4.8.16

Committed as fb9caaa6718c8553aeaf46a77ca5be7ac164a077 in 3547_cleanup.

comment:5 Changed 8 years ago by zaytsev

  • Blocked By 3547 added

comment:6 Changed 8 years ago by andrew_b

  • Blocked By 3547 removed

comment:7 Changed 8 years ago by andrew_b

  • Status changed from accepted to testing
  • Resolution set to fixed

comment:8 Changed 8 years ago by andrew_b

  • Status changed from testing to closed
Note: See TracTickets for help on using tickets.