Opened 12 years ago

Closed 11 years ago

#10973 closed defect (fixed)

Truncated output for showvminfo --machinereadable on Windows => Fixed in SVN

Reported by: Robb Kidd Owned by:
Component: other Version: VirtualBox 4.2.0
Keywords: Cc:
Guest type: all Host type: Windows


showvminfo --machinereadable output is truncated when using Virtualbox 4.2.0 on Windows 7 64-bit host.

C:\Users\robb.kidd>VBoxManage.exe showvminfo master --machinereadable
ostype="Ubuntu (64 bit)"

The problem appears to be with the character escaping in outputMachineReadableString (src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp:205).

Change History (6)

comment:1 by Robb Kidd, 12 years ago

While my C is not very good, I suspect the problem lies in line 227 of src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp which reads:

RTPrintf(".*s\\%c", psz - pszNext, *pszNext);

Judging by other calls to RTPrintf, should it be the following?

RTPrintf("%.*s\\%c", psz - pszNext, *pszNext);

comment:2 by Frank Mehnert, 12 years ago

Summary: Truncated output for showvminfo --machinereadable on WindowsTruncated output for showvminfo --machinereadable on Windows => Fixed in SVN

Thanks for the report. Your fix is correct. The next maintenance release will contain the fix.

in reply to:  2 comment:3 by Robb Kidd, 12 years ago

Knocking more rust off my string formatting, I'm looking at this line again and I'm confused by the %c now. If psz - pszNext and *pszNext together go into %.*s, what goes in to %c?

in reply to:  2 comment:4 by Robb Kidd, 12 years ago

I believe there is more wrong even with the update. Because the build environment for VirtualBox is not trivial, I played around with this function in a standalone program (also admittedly on Linux). So RTPrintf might behave differently than printf, but I doubt it differs too much on the formatting argument expectations.

The line as-is ...

  RTPrintf("%.*s\\%c", psz - pszNext, *pszNext);

... causes compiler errors: format %s expects a char* but got an int, %c expects an int and got nothing.

Adding psz in as the third argument ...

  RTPrintf("%.*s\\%c", psz - pszNext, psz, *pszNext);

... gets rid of the errors, but the output is incorrect: ab:cd:ef => ab:cd:ef\:cd:ef\:ef

(I used : as the character that needs escaping for clarity.)

Switching the operands in the subtraction ...

  RTPrintf("%.*s\\%c", pszNext - psz, psz, *pszNext);

... produces the expected output: ab:cd:ef => ab\:cd\:ef

comment:5 by Frank Mehnert, 12 years ago

The first fix was not correct but it should now be really fixed, see here. Thanks again.

comment:6 by Frank Mehnert, 11 years ago

Resolution: fixed
Status: newclosed

Fixed in 4.2.2.

Note: See TracTickets for help on using tickets.

© 2023 Oracle
ContactPrivacy policyTerms of Use