Contribute
Register

Patcho, a simple hex binary patcher

Status
Not open for further replies.

RehabMan

Moderator
Joined
May 2, 2012
Messages
183,805
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
Bug.

Patcho is overwriting the bounds of the argv array:
Code:
    if (embed[0] != '<' && argc == 1) {
        argv[1] = malloc(sizeof(embed));
        argv[2] = malloc(sizeof(embed));
        argv[3] = malloc(sizeof(embed));
        argv[4] = malloc(sizeof(embed));

If argc==1, then only argv[0] is valid.
argv[1...infinity] are outside the bounds of the array.
 

SJ_UnderWater

Moderator
Joined
Dec 3, 2010
Messages
461
Motherboard
Gigabyte GA-H55M-S2V
CPU
Intel i3-530
Graphics
HIS HD 6570
Mac
  1. iMac
Classic Mac
Mobile Phone
  1. Android
If you check the memory addresses of argv, this really isn't an issue, and you can confirm that by running it yourself. If you're really concerned, you could allocate another array on the stack, using it throughout, and remapping argv into it in the manually-entered case. Otherwise I wouldn't bother.
 

RehabMan

Moderator
Joined
May 2, 2012
Messages
183,805
Motherboard
Intel DH67BL
CPU
i7-2600K
Graphics
HD 3000
Mac
  1. MacBook Air
Mobile Phone
  1. iOS
If you check the memory addresses of argv, this really isn't an issue,

Not portable. Also, I don't see how 'checking the memory addresses of argv' can help. Without seeing the source for the code that calls main, there is simply no way to verify that these memory addresses aren't being used for something else.

and you can confirm that by running it yourself. If you're really concerned, you could allocate another array on the stack, using it throughout, and remapping argv into it in the manually-entered case. Otherwise I wouldn't bother.

I fixed it in the version I use.
 
Joined
Sep 29, 2012
Messages
4
Motherboard
G4 Cube
CPU
i3 3225
Graphics
hd 4000
Mac
Classic Mac
  1. Xserve
Mobile Phone
  1. iOS
Hey there,


the patch doesn't work with mavericks or do i need any other things with a dq77kb, on ML works flawless.

thanks
 
Status
Not open for further replies.
Top