seifzadeh / mp4v2

Automatically exported from code.google.com/p/mp4v2
Other
0 stars 0 forks source link

Wrong cast in "MP4BytesProperty::Dump" prevents ASCII hex dump log output. #106

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Dump the structure of any MP4 file which will lead to internal 
"MP4BytesProperty" nodes. This should apply to almost every MP4 file. E.g. 
">mp4file –dump file.mp4"

What is the expected output? What do you see instead?
The log output for "MP4BytesProperty" data shows a hex dump for the data byes 
(Ok) followed by a long series of numbers within the bar characters. The 
expected output would be to have the printable characters outputted instead of 
the decimal integer values within the bars, just like a common known "hex dump".

What version of the product are you using? On what operating system?
Trunk, rev. 470

Please provide any additional information below.
There is a wrong cast from "uint8_t" to "int" in "MP4BytesProperty::Dump" which 
prevents a proper hex dump log output. With the current code, all data bytes 
which are classified as "printable" are output as 'signed integer' decimal 
values – which leads to just a very long series of numbers. When casting the 
data bytes to 'char', the code will output the character values instead, which 
is very most likely what the code is supposed to do.

Index: src/mp4property.cpp
===================================================================
--- src/mp4property.cpp (revision 470)
+++ src/mp4property.cpp (working copy)
@@ -615,7 +615,7 @@
             if( i )
                 oss << ' ';
             oss << hex << setw(2) << setfill('0') << right << static_cast<uint32_t>(value[i]);
-            text << (isprint( static_cast<int>(value[i]) ) ? 
static_cast<int>(value[i]) : '.');
+            text << (isprint( static_cast<int>(value[i]) ) ? 
static_cast<char>(value[i]) : '.');
         }

         oss << "  |" << text.str() << "|";

Original issue reported on code.google.com by Skaa...@gmail.com on 1 Jun 2011 at 9:47

Attachments:

GoogleCodeExporter commented 8 years ago
Looks like a regression in the logging branch that was merged to main:

http://code.google.com/p/mp4v2/source/detail?r=423&path=/branches/logging/src/mp
4property.cpp

...yours is definitely right--the isprint() already took a static cast to int, 
and the point is to static cast the argument to char if it's printable.  Thanks 
for the fix, should be in r471.

Original comment by kid...@gmail.com on 1 Jun 2011 at 7:15