RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 757713 - File name completion in monitor can append '/' when it shouldn't
Summary: File name completion in monitor can append '/' when it shouldn't
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm
Version: 6.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Markus Armbruster
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-11-28 13:39 UTC by Markus Armbruster
Modified: 2013-01-10 00:34 UTC (History)
9 users (show)

Fixed In Version: qemu-kvm-0.12.1.2-2.211.el6
Doc Type: Bug Fix
Doc Text:
Cause: Monitor file name completion code checks for directory incorrectly; the result is random. Consequence: Completion can append a slash even when the completed name doesn't refer to a directory. Fix: Fix the check for directory. Result: Completion adds slash only when the completed name refers to a directory.
Clone Of:
Environment:
Last Closed: 2012-06-20 11:37:08 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2012:0746 0 normal SHIPPED_LIVE qemu-kvm bug fix and enhancement update 2012-06-19 19:31:48 UTC

Description Markus Armbruster 2011-11-28 13:39:17 UTC
Description of problem:
Completion appends '/' when it completes a directory name.  The code uses stat() to test, but ignores errors.  When stat() fails, it tests uninitialized stack memory.

How reproducible:
Always for me right now, but my recipe is not 100% reliable due to the nature of the bug.

Steps to Reproduce:
1. Create a directory and a dangling symbolic link:
$ mkdir dir
$ ln -s nonexist dangle
2. Run
$ qemu-kvm --nodefaults --enable-kvm -vnc :0 -m 384 -monitor stdio
3. Since the bug bites only when the stack contains the "right" crap bits, put them there by completing a directory name:
(qemu) screendump di
Do not hit <RET> here, just <TAB> to complete "di".
4. Complete the dangling symlink name.  Edit the current line to read
(qemu) screendump da
Then hit <TAB> again.

Actual results:
Step 3 completes "di" to "dir/"
Step 4 completes "da" to "dangle/"

Expected results:
Step 4 completes "da" to "dangle"

Additional info:
Fixed upstream in commit c951d9a6.

Comment 6 Chao Yang 2012-01-29 09:34:56 UTC
Reproduced this issue with following steps and environment:

# rpm -q qemu-kvm;uname -r
qemu-kvm-0.12.1.2-2.209.el6.x86_64
2.6.32-220.el6.x86_64

Steps:
1. Create a directory and a dangling symbolic link:
# mkdir abc
# ln -s a_filename_does_not_exist aaa
2. Launch a guest and issue below commands in monitor:
CLI:/usr/libexec/qemu-kvm -M rhel6.2.0 -enable-kvm -m 2048 -smp
2,sockets=1,cores=2,threads=1 -name test -uuid `uuidgen` -rtc
base=utc,clock=host,driftfix=slew -boot menu=on -drive
file=/home/test.qcow2,if=none,id=drive-virtio-0-0,media=disk,format=qcow2,cache=none,werror=stop,rerror=stop
-device virtio-blk-pci,drive=drive-virtio-0-0,id=virt0-0-0 -net none -usb
-device usb-tablet,id=input1 -spice port=9000,disable-ticketing -vga qxl
-global qxl-vga.vram_size=67108864 -monitor stdio -balloon none
2.1 
(qemu) screendump ab
Hit <TAB> to complete "abc"
2.2
(qemu) screendump aa
Hit <TAB> to complete "aaa"

Actual Result:
After step 2.1, it completes "ab" to "abc/"
After step 2.2, it completes "aa" to "aaa/"(it shouldn't append '/')

-------------
Verified in the following environment with same steps and CLI mentioned above.
# rpm -q qemu-kvm;uname -r
qemu-kvm-0.12.1.2-2.221.el6.x86_64
2.6.32-220.el6.x86_64

Actual Result:
After step 2.2, it completes "aa" to "aaa" instead of "aaa/", and screendump could save a correct snapshot by both "screendump abc/sn" and "aaa"


--------------
Base on above, this issue has been fixed.

Comment 9 Michal Novotny 2012-05-04 09:24:16 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause:
stat() can fail for file just read with readdir() and file_completion() uses uninitialized st_mode.

Consequence:
Slash character can be appended if directory bit happens to be set.

Fix:
[NEEDINFO: Markus, could you please add it? Thanks!]

Result:
File name is valid and doesn't refer to a non-existing directory

Comment 10 Markus Armbruster 2012-05-04 10:10:50 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,11 +1,11 @@
 Cause:
-stat() can fail for file just read with readdir() and file_completion() uses uninitialized st_mode.
+Monitor file name completion code checks for directory incorrectly; the result is random.
 
 Consequence:
-Slash character can be appended if directory bit happens to be set.
+Completion can append a slash even when the completed name doesn't refer to a directory.
 
 Fix:
-[NEEDINFO: Markus, could you please add it? Thanks!]
+Fix the check for directory.
 
 Result:
-File name is valid and doesn't refer to a non-existing directory+Completion adds slash only when the completed name refers to a directory.

Comment 11 errata-xmlrpc 2012-06-20 11:37:08 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0746.html


Note You need to log in before you can comment on or make changes to this bug.