On Sat, May 31, 2014 at 03:01:51PM +0000, Dmitry Chagin wrote:
> Author: dchagin
> Date: Sat May 31 15:01:51 2014
> New Revision: 266925
> URL: http://svnweb.freebsd.org/changeset/base/266925
> 
> Log:
>   To allow to run the interpreter itself add a new ELF branding type.
>   Allow Linux ABI to run ELF interpreter.
>   

[..]

> +     /* Some ABI allows to run the interpreter itself. */
> +     for (i = 0; i < MAX_BRANDS; i++) {
> +             bi = elf_brand_list[i];
> +             if (bi == NULL || bi->flags & BI_BRAND_NOTE_MANDATORY)
> +                     continue;
> +             if (hdr->e_machine != bi->machine ||
> +                 (bi->flags & BI_CAN_EXEC_INTERP) == 0)
> +                     continue;
> +             /*
> +              * Compare the interpreter name not the path to allow run it
> +              * from everywhere.
> +              */
> +             interp_brand_name = strrchr(bi->interp_path, '/');
> +             if (interp_brand_name == NULL)
> +                     interp_brand_name = bi->interp_path;
> +             interp_len = strlen(interp_brand_name);
> +             fname_name = strrchr(imgp->args->fname, '/');

Don't know about the rest, but this part looks incorrect.

fname is NULL (which will crash in strrchr) when fexecve is executed.

> +             if (fname_name == NULL)
> +                     fname_name = imgp->args->fname;
> +             fname_len = strlen(fname_name);
> +             if (fname_len < interp_len)
> +                     continue;
> +             ret = strncmp(fname_name, interp_brand_name, interp_len);
> +             if (ret == 0)
> +                     return (bi);
> +     }
> +


-- 
Mateusz Guzik <mjguzik gmail.com>
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to