Opened 12 years ago
Closed 12 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 |
Description
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 name="master" groups="/" ostype="Ubuntu (64 bit)" UUID="fe63ef8e-8fab-496a-9634-1cbfdf319fde" CfgFile=".*s\
The problem appears to be with the character escaping in outputMachineReadableString (src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp:205).
Change History (6)
comment:1 by , 12 years ago
follow-ups: 3 4 comment:2 by , 12 years ago
Summary: | Truncated output for showvminfo --machinereadable on Windows → 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 by , 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
?
comment:4 by , 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 , 12 years ago
The first fix was not correct but it should now be really fixed, see here. Thanks again.
While my C is not very good, I suspect the problem lies in line 227 of src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp which reads:
Judging by other calls to RTPrintf, should it be the following?