[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash 4.4 null byte warning!!

From: Greg Wooledge
Subject: Re: bash 4.4 null byte warning!!
Date: Mon, 10 Apr 2017 09:16:12 -0400
User-agent: Mutt/

On Mon, Apr 10, 2017 at 05:08:10AM +0000, address@hidden wrote:
>  FIND_RPM="$(find $linIdx -type d -name "${2}" -print0 2>/dev/null)"
>         [ -n "$FIND_RPM" ] && \
>             [ -s "${FIND_RPM}/bin" ] && \
>             bdt_msg 4 "[D] Found %s in %s component area." "$2" "$linIdx" && \

"$FIND_RPM/bin" indicates that your code assumes find will only return
a single directory name.  If find returned two things, you would end up
constructing a path like /thing/one/thing/two/bin.

-print0 makes find print a NUL byte after each filename found.  It's used
to safely serialize filenames into an output stream, since filenames may
contain spaces, tabs, newlines, and so on.  In your case, it's not actually
helping you.  If find returns two or more things, your script is already
broken, and the NUL delimiter between filenames won't save you.

The whole time you have been using this script in the past, find has been
adding a NUL byte (because of -print0) and then bash's command substitution
has been silently removing it.  The only thing that changed in 4.4 is now,
when bash removes the NUL, it issues a warning message.  That's all.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]