| Chewbob (95) | |||
I have this code which is supposed to convert an URL to the form in which it is used in a DNS request:
For some reason it is acting very strangely. Sometimes it gives me the correct output and sometimes it doesn't. For example, if the executable is abc.exe, when I run it like this from the command line (on Windows): abc qwe.rtyui.op.as I get this output: 156 3qwe5rtyui2op2as6m-448B<248-56Z3-16Z3 Z3-120Z3-56Z3-24Z3< Z3h Z3-120 Z3-88 Z3-32 Z38!Z3 !Z3@!Z3-64!Z38"Z3-40"Z316#Z30#Z3P#Z3h#Z3-56%Z316&Z38&Z3-120&Z3-88&Z3-56&Z3-16&Z3<'Z30'Z3-128'Z3-96'Z3-32'Z However, if I run it like this: abc.exe qwe.rtyui.op.as I get this output: 16 3qwe5rtyui2op2as The second of which is the expected output. If I strcpy() argv[1] into a separate string, sometimes I got the path to the program mixed in with the output, for example: 3qwe5rtyui2op2as1V1o1l1u1m1e1\1U1s1e1r1s1\1M1a1t1t1\1D1e1s1k1t1o1p1 Which is the path the the program with 1s in between every character. The output varies depending on what I type at the command line. Any help would be appreciated. | |||
|
Last edited on
|
|||
| kbw (4342) | |
| Have you tried debugging it? You really should give it a try. | |
|
|
|
| helios (9442) | |
| Line 27 will produce a buffer overflow on line 28 when the loop from line 16 breaks because !*p. | |
|
|
|
| Chewbob (95) | |
|
Thanks helios, can't believe I didn't spot that after staring at my screen for so long. Thank you both for your suggestions. | |
|
|
|