[OpenBIOS] [PATCH 1/6] bootinfo_load: recognize ASCII EOT as end of bootinfo

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Sat Jun 20 23:40:08 CEST 2015


On 20/06/15 18:48, Cormac O'Brien wrote:

> Mac OS 9's CHRP boot info consists of the standard SGML document terminated by
> an ASCII EOT, followed by a large binary blob which is relocated by the Forth
> script. This patch allows the bootinfo loader to stop loading the script if it
> detects an EOT, avoiding the out-of-memory error previously encountered when
> booting OS 9.
> 
> Signed-off-by: Cormac O'Brien <i.am.cormac.obrien at gmail.com>
> ---
>  libopenbios/bootinfo_load.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/libopenbios/bootinfo_load.c b/libopenbios/bootinfo_load.c
> index fa9e36b..4b6a52c 100644
> --- a/libopenbios/bootinfo_load.c
> +++ b/libopenbios/bootinfo_load.c
> @@ -161,6 +161,16 @@ bootinfo_init_program(void)
>  	feval("load-size");
>  	size = POP();
>  
> +	/* Check for a delimiting ASCII EOT, as in Mac OS 9 */
> +	current = 0;
> +	while (current < size) {
> +		if (base[current] == 0x04) {
> +			size = current;
> +			break;
> +		}
> +		current++;
> +	}
> +
>  	bootscript = malloc(size);
>  	if (bootscript == NULL) {
>  		DPRINTF("Can't malloc %d bytes\n", size);
> 

I've checked this patch with a debugger, and I think the use of EOT to
detect the end of the bootscript isn't correct. AFAICT with gdb the
Forth string is always NULL-terminated which is eluded to in the
IEEE1275 specification in an indirect manner in section 6.3.2.6. Note
that the patch above does work due to the position of a suitable EOT
character but in my testing here it is several KB into the binary image
rather than directly at the end of the Forth boundary.

I have an even simpler patch to replace this that I'll post to the list
shortly.


ATB,

Mark.




More information about the OpenBIOS mailing list