logo       

Re: patch to login, dmesg and obscure: msg#00219

linux.busybox

Subject: Re: patch to login, dmesg and obscure


> Example:
> old = "123" (4 bytes)
> wrapped allocated = 3*2 + 1 = 7 bytes.
> first initialisez only 4 bytes = "123"
> after strcat resut is "123123" - 7 bytes.
> Not overflow.



This start to be realy fun soon... :-) The litte prog below mimics
password_check() behaviour and it sure craches on my machine. Howcome?
It shouldn't if you're right.

/Ronny


----------------
#include <string.h>
#include <stdio.h>
#include <stdlib.h>


int main(void) {
const char *old="0123456789";
char *wrapped;
int lenwrap;

lenwrap = strlen(old) * 2 + 1;
wrapped = malloc(lenwrap);
strcpy(wrapped, old);

strcat(wrapped, wrapped);
printf("wrapped: %s\n", wrapped);

free(wrapped);
return 0;
}


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise