0neblock / libcrafter

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

Bug on the RawString method of the Layer class #6

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

        RawLayer raw_header;
        raw_header.SetPayload("SomePayload");
        raw_header.RawString();

What is the expected output? What do you see instead?

The program should print the hex string of the raw header, instead a 
segmentation fault happens. 

Program received signal SIGSEGV, Segmentation fault.
0x001616a5 in Crafter::Layer::RawString (this=0xbffff5b4) at 
crafter/Layer.cpp:109
109         std::cout << std::hex << (unsigned int)((byte *)raw_data)[i];
(gdb) where
#0  0x001616a5 in Crafter::Layer::RawString (this=0xbffff5b4) at 
crafter/Layer.cpp:109
#1  0x08049bbf in main ()
(gdb) p i
$1 = 0
(gdb) list crafter/Layer.cpp:109
104 /* Print Payload */
105 void Crafter::Layer::RawString() const {
106     /* Print raw data in hexadecimal format */
107     for(size_t i = 0 ; i < bytes_size ; i++) {
108         std::cout << "\\x";
109         std::cout << std::hex << (unsigned int)((byte *)raw_data)[i];
110     }
111 
112     LayerPayload.Print();
113 

There is a bug on the RawString method of the Layer class.

Original issue reported on code.google.com by pellegre...@gmail.com on 22 Apr 2012 at 10:57

GoogleCodeExporter commented 8 years ago

Original comment by pellegre...@gmail.com on 23 Apr 2012 at 6:32