Bug 1473642

Summary: /usr/sbin/clamav-notify-servers: line 72: warning: command substitution: ignored null byte in input
Product: [Fedora] Fedora Reporter: Juan Orti <jorti>
Component: clamavAssignee: Sergio Basto <sergio>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 26CC: amessina, bugzilla.redhat.com, cegolf, crow, dan, dick, fedora.jrg01, frank, gbcox, john, j, martin, nberrehouc, ondrejj, orion, redhat-bugzilla, sauchter, sergio, steve, tom, tommy, tr-rh
Target Milestone: ---Flags: tommy: needinfo-
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: clamav-0.99.2-12.fc27 clamav-0.99.2-12.fc26 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-09-30 06:36:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Juan Orti 2017-07-21 11:18:43 UTC
Description of problem:
I'm getting these when updating clamav:

/usr/sbin/clamav-notify-servers: lĂ­nea 72: aviso: command substitution: ignored null byte in input

line 72 is:

resp=`printf 'zRELOAD\0' | timeout ${K_OPT:+-k $TIMEOUT_KILL} $TIMEOUT_TERM "${CMD[@]}"`

Version-Release number of selected component (if applicable):
clamav-server-0.99.2-1.fc25.x86_64
clamav-0.99.2-1.fc25.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Activate clamav updates in /etc/sysconfig/freshclam, /etc/freshclam.conf and /etc/cron.d/clamav-update

2. Configure server notification in /etc/freshclam.conf
NotifyClamd /etc/clamd.d/amavisd.conf

Actual results:
I receive the warning by email

Comment 1 Sergio Basto 2017-07-21 11:53:00 UTC
Could you test clamav-0.99.2-9.fc25 ?

https://bodhi.fedoraproject.org/updates/?packages=clamav

Comment 2 Juan Orti 2017-07-21 14:31:07 UTC
The same error with clamav-0.99.2-9.fc25

Comment 3 Juan Orti 2017-07-21 14:35:32 UTC
Looks like it's a new feature of bash-4.4:

https://lists.gnu.org/archive/html/bug-bash/2016-09/msg00015.html

Comment 4 Jason Tibbitts 2017-07-21 21:42:27 UTC
This is kind of weird.  I don't think bash is complaining about the explicit NUL in the printf argument; it's complaining the that output of the timeout command contains a NUL which is thrown away.  I wonder what that output is and whether the NUL values in it are supposed to be somehow significant.

Since bash has always thrown away NUL bytes in this manner and is only just now warning about it, I guess it should be safe to add a "| tr -d \\0" on the end there.  That would be better than redirecting stdout to /dev/null, certainly.  But there's probably still a better way.

Comment 5 Sergio Basto 2017-07-21 23:28:59 UTC
*** Bug 1473867 has been marked as a duplicate of this bug. ***

Comment 6 Tommy Hurtig 2017-07-22 15:26:40 UTC
It seems to me like changing the script to this fix the problem:

    printf 'zRELOAD\0' |  timeout ${K_OPT:+-k $TIMEOUT_KILL} $TIMEOUT_TERM "${CMD[@]}" | { read resp
      case $resp in
        (RELOADING)
          ;;
        (*)
          echo "clamd server '$i' gave '$resp' response" >&2
          let ++fail
          ;;
      esac
    }

Then using this, command substitution won't be used, and the new behaviour in bash 4.4 won't be triggered. I'n uncertain if there are any drawbacks?

There is some discussion about this behaviour in https://lists.gnu.org/archive/html/bug-bash/2016-09/msg00015.html

Comment 7 Sergio Basto 2017-08-01 10:44:24 UTC
Hi, 

(In reply to Juan Orti from comment #0)

> Actual results:
> I receive the warning by email

This not affect the functionally of it , isn't it ? 

Thanks

Comment 8 dan 2017-08-01 13:43:58 UTC
Aside from flooding the forwarded root mbox with warning messages!

Comment 9 Juan Orti 2017-08-07 10:30:36 UTC
(In reply to Sergio Monteiro Basto from comment #7)
> This not affect the functionally of it , isn't it ? 

clamd reloads the database fine, the only inconvenience is the warning messages.

Comment 10 John Griffiths 2017-08-12 14:07:34 UTC
The bug thread in  https://lists.gnu.org/archive/html/bug-bash/2016-09/msg00015.html started 15 Sep 2016 and ended 20 Sep 2016.

Based on that, I don't think the behavior of bash is going to change, so the script is going to have to change to account for the bash 4.4 behavior. I personally think the bash 4.4 behavior is against the UNIX "Silence is golden" policy, but my opinion counts for nothing.

This should probably go upstream since it may effect any distro the is using bash 4.4.

Comment 11 Nicolas Berrehouc 2017-08-15 14:21:10 UTC
Same error after upgrading from F25 to F26 this morning.
clamav-0.99.2-9.fc26.x86_64 and bash-4.4.12-7.fc26.x86_64

Comment 12 John Griffiths 2017-08-18 13:27:37 UTC
(In reply to Tommy Hurtig from comment #6)
> It seems to me like changing the script to this fix the problem:
> 
>     printf 'zRELOAD\0' |  timeout ${K_OPT:+-k $TIMEOUT_KILL} $TIMEOUT_TERM
> "${CMD[@]}" | { read resp
>       case $resp in
>         (RELOADING)
>           ;;
>         (*)
>           echo "clamd server '$i' gave '$resp' response" >&2
>           let ++fail
>           ;;
>       esac
>     }
> 
> Then using this, command substitution won't be used, and the new behaviour
> in bash 4.4 won't be triggered. I'n uncertain if there are any drawbacks?
> 
> There is some discussion about this behaviour in
> https://lists.gnu.org/archive/html/bug-bash/2016-09/msg00015.html

Made this edit to the script and no longer get warning.

Comment 13 Sergio Basto 2017-08-25 19:54:33 UTC
*** Bug 1485461 has been marked as a duplicate of this bug. ***

Comment 14 Sergio Basto 2017-09-15 17:30:11 UTC
(In reply to Tommy Hurtig from comment #6)
> It seems to me like changing the script to this fix the problem:
> 
>     printf 'zRELOAD\0' |  timeout ${K_OPT:+-k $TIMEOUT_KILL} $TIMEOUT_TERM
> "${CMD[@]}" | { read resp
>       case $resp in
>         (RELOADING)
>           ;;
>         (*)
>           echo "clamd server '$i' gave '$resp' response" >&2
>           let ++fail
>           ;;
>       esac
>     }
> 
> Then using this, command substitution won't be used, and the new behaviour
> in bash 4.4 won't be triggered. I'n uncertain if there are any drawbacks?
> 
> There is some discussion about this behaviour in
> https://lists.gnu.org/archive/html/bug-bash/2016-09/msg00015.html

can you provide code in a patch ? please ,

Comment 15 Sergio Basto 2017-09-15 18:41:07 UTC
ah clamav-notify-servers  is not from clamav source code , so only Fedora have this problem . Patch applied [1] , please test and verify , thanks 

[1] 
https://src.fedoraproject.org/cgit/rpms/clamav.git/commit/?id=f5e72a7773d6be5e9c99ae2edcb2754d503e9f87

https://src.fedoraproject.org/rpms/clamav/c/f5e72a7773d6be5e9c99ae2edcb2754d503e9f87?branch=master

Comment 16 Fedora Update System 2017-09-15 19:27:01 UTC
clamav-0.99.2-12.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2017-558529554f

Comment 17 Fedora Update System 2017-09-15 19:28:06 UTC
clamav-0.99.2-12.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-365b0241af

Comment 18 Fedora Update System 2017-09-16 18:22:21 UTC
clamav-0.99.2-12.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-558529554f

Comment 19 Fedora Update System 2017-09-17 10:50:39 UTC
clamav-0.99.2-12.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-365b0241af

Comment 20 Fedora Update System 2017-09-30 06:36:22 UTC
clamav-0.99.2-12.fc27 has been pushed to the Fedora 27 stable repository. If problems still persist, please make note of it in this bug report.

Comment 21 John Griffiths 2017-09-30 08:53:31 UTC
Is this going to be pushed to FC26?

Comment 22 Sergio Basto 2017-09-30 13:44:09 UTC
(In reply to John Griffiths from comment #21)
> Is this going to be pushed to FC26?

yes, but you may give positive karma and it will be automatic pushed , (I prefer this because ensures that we got tested ) 
Anyway I'm pushing it now .

Comment 23 Fedora Update System 2017-10-02 02:49:38 UTC
clamav-0.99.2-12.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.