bugGNU GRUB - Bugs: bug #44115, test EXPR1 -a EXPR2 always true...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #44115: test EXPR1 -a EXPR2 always true when EXPR1 deals with existing filesystem object

Submitter:  adrian15 <adrian15sgd>
Submitted:  Thu 29 Jan 2015 07:00:40 AM UTC
   
 
Category:  Terminal Severity:  Major
Priority:  5 - Normal Item Group:  Software Error
Status:  Fixed Privacy:  Public
Assigned to:  None Originator Name: 
Open/Closed:  Closed Release:  Git master
Release:  Reproducibility:  Every Time
Planned Release:  None

Fri 30 Jan 2015 06:44:03 PM UTC, comment #4: 

Fixed from 1e047e53aeb684a3a21a4269a99c708c381b96b5 on together with test case.

Andrei Borzenkov <arvidjaar>
Group Member
Fri 30 Jan 2015 06:00:36 AM UTC, comment #3: 

@Andrei: go ahead to commit your patch and close the bug. Could you also add a test?

Vladimir Serbinenko <phcoder>
Group administrator
Thu 29 Jan 2015 11:58:45 PM UTC, comment #2: 

Yes, it helps!

Thank you very much!

Now the results are the expected ones.

-----

grub> if test "one" = "one" -a "one" = "two" ; then echo "yes" ; else echo "no"
; fi
no
grub> if test -f $prefix/grub.cfg -a "one" = "two" ; then echo "yes" ; else echo
 "no" ; fi 
no
grub> if test "one" = "two" -a -f $prefix/grub.cfg ; then echo "yes" ; else echo
 "no" ; fi 
no

adrian15 <adrian15sgd>
Thu 29 Jan 2015 03:27:09 PM UTC, comment #1: 

Does attached patch help?

(file #32940)

Andrei Borzenkov <arvidjaar>
Group Member
Thu 29 Jan 2015 07:00:40 AM UTC, original submission:  

Jessie chroots - Package I installed
--------------------------------------------

python autoconf bison flex unicode libfreetype6-dev

Affected GIT commit
-------------------

2da4171eabfe0d1b9b1be6146f628099d08aac02

Build system
-------------

Jessie from 12 January 2015
Build options

./configure --with-platform=efi at first pass.
./configure --with-platform=pc at second pass.

How do I build and prepare my system
------------------------------------
Make sure no Debian grub package is found in chroot

apt-get remove '.grub.'
Grub2 (efi+pc)) Build and installation

# Make sure we are testing the right revision
mkdir grub_upstream
cd grub_upstream
git clone git://git.savannah.gnu.org/grub.git .
git checkout COMMIT-TO-TEST
# Remove any non git related file - BEGIN
git reset --hard
git clean -f -d
git clean -f -x -d

# Remove any non git related file - END
# Build efi based grub and install it - BEGIN
./autogen.sh && ./configure --enable-grub-mkfont --with-platform=efi && make
# Dont forget to delete any rest of previous installation - BEGIN
sudo rm -rf /usr/local/etc/grub.d/ /usr/local/bin/grub-* /usr/local/share/grub/
# Dont forget to delete any rest of previous installation - END
sudo make install
# Build efi based grub and install it - END
make clean # Prepare for next build
./configure --enable-grub-mkfont --with-platform=pc && make # Prepare for a i386 build
sudo make install # Install i386 build

Super Grub2 Disk build
----------------------
grub-mkrescue --output=/tmp/test1.iso

VM system
----------
QEMU emulator version 2.1.2 (Debian 2.1+dfsg-7+b1)

kvm -bios /usr/share/ovmf/OVMF.fd -boot c -hda /home/adrian/gnu/rescatux/jessie_chroot/tmp/sg2d_efi_hdd.iso

How to reproduce the bug
-------------------------
If needed press 'c' to go to grub shell.

# When the evaluation is true we print "yes"
# When the evaluation is false we print "no"

# Let's begin with a simple example

if test "one" = "one" -a "one" = "two" ; then echo "yes" ; else echo "no" ; fi

# The output is, as expected, "no".

# Now you should know that $prefix/grub.cfg exists in my grub2 disk

# Now let's make arise the bug

if test -f $prefix/grub.cfg -a "one" = "two" ; then echo "yes" ; else echo "no" ; fi

# The output is "yes" while I was expecting it to be "no" !!!

# Now I'm going to try to inverse the order

if test  "one" = "two" -a -f $prefix/grub.cfg ; then echo "yes" ; else echo "no" ; fi

# The output is, as expected, "no"

# Individual tests so that you see that they are ok

if test -f $prefix/grub.cfg ; then echo "yes" ; else echo "no" ; fi

# The output is, as expected, "yes"

if test -f $prefix/noexists.cfg ; then echo "yes" ; else echo "no" ; fi

# The output is, as expected, "no"

if test  "one" = "two" ; then echo "yes" ; else echo "no" ; fi

# The output is, as expected, "no"

# Let's check if it's variable parsing related

if test -f (hd0)/boot/grub/grub.cfg -a "one" = "two" ; then echo "yes" ; else echo "no" ; fi

# The output is "yes" while I was expecting it to be "no" !!! That probably means that variable parsing is not involved in the bug

# Let's try with "test -d" which seems similar to "test -f"

if test -d (hd0)/boot/grub -a "one" = "two" ; then echo "yes" ; else echo "no" ; fi

# The output is "yes" while I was expecting it to be "no" !!! That probably means that this bug affects not only "test -f" but also expression evaluation which handle opening of filesystem objects

# Additional information

  • Quoting with (") $prefix/grub.cfg makes no difference.
  • I have not been able to check at first place the bug with grub developers so please check if I'm writing the if test else commands as I'm supposed to or I'm adding non POSIX syntax or whatever I'm doing wrong.


Thank you for taking a look at the bug.

adrian15 <adrian15sgd>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #32940:  44115.diff added by arvidjaar (2KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by phcoder (Posted a comment)
  • -email is unavailable- added by arvidjaar (Updated the item)
  • -email is unavailable- added by adrian15sgd (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-01-30 arvidjaar StatusNone Fixed
        Open/ClosedOpen Closed
    2015-01-29 arvidjaar Attached File- Added 44115.diff, #32940

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code