PVR-9200T Data Recovery

Now there's an improved version on my github repo: github.com/Pauligrinder/humaxrw/releases/tag/v2026.4

Along with the aforementioned improvements and fixes, I also added a GUI (which I haven't tested because I don't have a disk image or drive at hand right now). Anyway, it uses the cli-app directly so the same stuff should work from that just as well.
 
I've attached ts_align.zip containing the source code
Code:
               char out_name [sizeof (argv [i]) + 2];

               sprintf (out_name, "%sa", argv [i]);
You need to fix this, which will almost certainly cause a memory overwrite unless you have a very short filename.
sizeof(argv[i]) does NOT return the length of the string in argv[i] - it returns the size of "char *", which is a very different thing.
 
Code:
               char out_name [sizeof (argv [i]) + 2];

               sprintf (out_name, "%sa", argv [i]);
You need to fix this, which will almost certainly cause a memory overwrite unless you have a very short filename.
sizeof(argv[i]) does NOT return the length of the string in argv[i] - it returns the size of "char *", which is a very different thing.
It's a classic bug that one, seen similar several times in my career writing software.
 
I believe so, although I've never done it myself or seen it (until now).
It's generally people experienced in other languages moving to C that mix up sizeof and strlen like this. People that learn C as their main language when they start programming as I did don't tend to do this one. 20 years ago (out of a 40 year career) I'd never seen it, but it and similar issues are becoming more common as people move around between languages more and interpreted languages that manage all this for you (like Python) become more common.
 
People that learn C as their main language when they start programming as I did don't tend to do this one.
I taught myself C, after learning Fortran and Basic during my Elec. Eng. degree, and Pascal with an engineering consultancy, and have never found myself using sizeof for strings.
 
Sorry, you are quite right. New version attached.
Yes, but did you actually try to compile it? Clearly not.
You can't use strlen() as the size of an array at compile time as it's a run-time thing. If you're going to do it like this then you need to use malloc()/free() etc.
 
I taught myself C, after learning Fortran and Basic during my Elec. Eng. degree
Cecil, Basic and self-taught Fortran at school. Then they made us do Pascal as Uni. (* insert stupid comment here *) and then I taught myself C. Then I taught myself properly at first job with a computer company. Far too late in the day for C++ though (again self-taught) but I was doing other stuff by then.
 
Back
Top