I have following program
#include <iostream>
#include <string.h>
int main(int argc, char* argv[])
{
std::cout << std::hex << (int) argv[1][0];
std::cout << std::hex << (int) argv[1][1];
std::cout << std::hex << (int) argv[1][2];
std::cout << std::hex << (int) argv[1][3];
std::cout << std::endl;
size_t len = strlen(argv[1]);
std::cout << "Len: " << len << std::endl;
return 0;
}
When I run it in this way:
./a.out $(python -c "print '\x01\x01\x01\x01'")
the output is:
1111
Len: 4
But when I run it in this way:
./a.out $(python -c "print '\x21\xdd\x09\xec'")
the output differs significantly.
21ffffffdd0ffffffec
Len: 2
I can't figure out why is that. It is probably something that is obvious, but I can't grasp it.
Especially I'm interested in - why strlen does not work as expected by me.