Bug 597135 - guestfish write-file cmd does not check "size" parameter
guestfish write-file cmd does not check "size" parameter
Product: Virtualization Tools
Classification: Community
Component: libguestfs (Show other bugs)
All Linux
low Severity medium
: ---
: ---
Assigned To: Richard W.M. Jones
Depends On:
  Show dependency treegraph
Reported: 2010-05-28 04:18 EDT by Pengzhen Cao
Modified: 2011-07-14 15:12 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2011-07-14 15:12:06 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
guestfish write-file cmd logs (224.17 KB, text/plain)
2010-05-28 04:18 EDT, Pengzhen Cao
no flags Details

  None (edit)
Description Pengzhen Cao 2010-05-28 04:18:43 EDT
Created attachment 417508 [details]
guestfish write-file cmd logs

Description of problem:
guestfish write-file cmd does not check the size parameter, this cause two issues:
1. if size is greater than the actual string length, random content will returned and written to the file, I guess it just overflow the char* pointer address and dump the XDR buffer to file
2. if size is negative or a great value that exceeds XDR buffer,will cause "bad address" error

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. run guestfish with an existing image
2. issue cmd " write-file /t.txt  "abcdefg" SIZE
3. SIZE could be some vaule great than the string leng, such as 10000
Actual results:
random content will return with size larger than actual string length

Expected results:
Should not return random content nor "bad address" error, size should be checked in do_write_file function

Additional info:
logs appended
Comment 1 Richard W.M. Jones 2010-06-01 11:22:27 EDT
Patch posted upstream:
Comment 2 Fedora Update System 2010-06-02 17:12:28 EDT
libguestfs-1.2.9-1.el5 has been submitted as an update for Fedora EPEL 5.
Comment 3 Fedora Update System 2010-06-02 17:26:15 EDT
libguestfs-1.2.9-1.fc13 has been submitted as an update for Fedora 13.
Comment 4 Richard W.M. Jones 2010-06-02 17:33:02 EDT
This patch has been pushed upstream.

If this needs to be fixed for RHEL 5 / 6, please clone
this bug and adjust the Product accordingly.
Comment 5 Fedora Update System 2010-06-03 04:48:53 EDT
libguestfs-1.2.9-1.el5.1 has been submitted as an update for Fedora EPEL 5.

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