Re,

Again, this is mixing various changes that really deserve their own
patch, to be able to git bisect in case of regressions.

Alperen Erkan, le dim. 20 sept. 2026 11:59:03 +0300, a ecrit:
> diff --git a/hurd/boot/boot_script.c b/hurd/boot/boot_script.c
> --- a/hurd/boot/boot_script.c
> +++ b/hurd/boot/boot_script.c
> @@ -1,6 +2,7 @@
>  /* Boot script parser for Mach.  */
> 
>  /* Written by Shantanu Goel ([2][email protected]).  */
> +/* Copyright (C) 2026 Alperen ERKAN */

Again, no.

> 
>  #include <mach/mach_types.h>
>  #if !KERNEL || OSKIT_MACH
> @@ -340,7 +343,10 @@ boot_script_parse_line (void *hook, char *cmdline)
> 
>        /* Only values are allowed in ${...} constructs.  */
>        if (end_char == '}' && s->type == VAL_FUNC)
> - return BOOT_SCRIPT_INVALID_SYM;
> + {
> +  error = BOOT_SCRIPT_INVALID_SYM;
> +  goto bad;
> + }

That should be separate.

> 
>        /* Check that assignment is valid.  */
>        if (c == '=' && s->type == VAL_FUNC)
> @@ -559,9 +567,17 @@ boot_script_exec (void)
>   {
>    struct sym *sym = (struct sym *) arg->val;
> 
> -  /* Resolve symbol value.  */
> -  while (sym->type == VAL_SYM)
> +  /* Resolve symbol value.  Guard against reference
> +     cycles.  */
> +  unsigned int depth = 0;
> +  while (sym->type == VAL_SYM
> + && depth++ <= (unsigned int) symtab_index)
>      sym = (struct sym *) sym->val;
> +  if (sym->type == VAL_SYM)
> +    {
> +      error = BOOT_SCRIPT_SYNTAX_ERROR;
> +      goto done;
> +    }

As well as that.

>    if (sym->type == VAL_NONE)
>      {
>        error = BOOT_SCRIPT_UNDEF_SYM;


> @@ -39,6 +77,44 @@
>  #include "boot_script.h"
>  #include "private.h"
> 
> +/* Read exactly LEN bytes from FD, returning 0 on success.  */
> +static int
> +read_full (int fd, void *buf, size_t len)
> +{
> +  char *p = buf;
> +  while (len > 0)
> +    {
> +      ssize_t n = read (fd, p, len);
> +      if (n == 0)
> + return -1;
> +      if (n < 0)
> + {
> +  if (errno == EINTR)
> +    continue;
> +  return -1;
> + }
> +      p += n;
> +      len -= n;
> +    }
> +  return 0;
> +}
> +
> +static void
> +write_str (const char *msg, size_t len)
> +{
> +  ssize_t err;
> +  do
> +    err = write (2, msg, len);
> +  while (err < 0 && errno == EINTR);
> +}

Keep them together, they have the same role. And introduce them in their
own patch, separate from the other kinds of load checks, since they have
a really different effect.

> @@ -163,9 +168,14 @@ boot_script_insert_right (struct cmd *cmd, mach_port_t
> port, mach_port_t *name)
>    *name = MACH_PORT_NULL;
>    do
>      {
> +      if (*name >= (1 << 20))

What is this magic value?

Samuel

Reply via email to