Ticket #10973 (closed defect: fixed)

Opened 9 years ago

Last modified 9 years ago

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

comment:1 Changed 9 years ago by Robb Kidd

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 follow-ups: ↓ 3 ↓ 4 Changed 9 years ago by frank

  • Summary changed from Truncated output for showvminfo --machinereadable on Windows to Truncated 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.

comment:3 in reply to: ↑ 2 Changed 9 years ago by Robb Kidd

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?

comment:4 in reply to: ↑ 2 Changed 9 years ago by Robb Kidd

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 Changed 9 years ago by frank

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

comment:6 Changed 9 years ago by frank

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in 4.2.2.

Note: See TracTickets for help on using tickets.
ContactPrivacy policyTerms of Use