[BusyBox] patch to login, dmesg and obscure

Ronny L Nilsson bb at arbetsmyra.dyndns.org
Mon Jul 28 16:09:41 UTC 2003


> 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;
}










More information about the busybox mailing list