|
Message-ID: <20220405044359.GA8499@voyager> Date: Tue, 5 Apr 2022 06:43:59 +0200 From: Markus Wichmann <nullplan@....net> To: musl@...ts.openwall.com Cc: Colin Cross <ccross@...gle.com> Subject: Re: [PATCH] dl_iterate_phdr: return empty string for the name of the main program On Mon, Apr 04, 2022 at 08:18:59PM -0700, Colin Cross wrote: > diff --git a/ldso/dynlink.c b/ldso/dynlink.c > index fd0d38e9..d2e22a0b 100644 > --- a/ldso/dynlink.c > +++ b/ldso/dynlink.c > @@ -2323,12 +2323,15 @@ no_redir: > > int dl_iterate_phdr(int(*callback)(struct dl_phdr_info *info, size_t size, void *data), void *data) > { > + static const char* empty_string = ""; > struct dso *current; > struct dl_phdr_info info; > int ret = 0; > for(current = head; current;) { > info.dlpi_addr = (uintptr_t)current->base; > - info.dlpi_name = current->name; > + /* glibc uses an empty string for the main program */ > + info.dlpi_name = (current == head) ? empty_string : > + current->name; > info.dlpi_phdr = current->phdr; > info.dlpi_phnum = current->phnum; > info.dlpi_adds = gencnt; > -- > 2.35.1.1094.g7c7d902a7c-goog > Any particular reason you chose to create an object for the empty string, instead of just using an empty string? I.e. why not just info.dlpi_name = current==head? "" : current->name; Ciao, Markus
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.