From: "Marcus Müller" <marcus_zsh@hostalia.de>
To: "Philippe Troin" <phil@fifi.org>,
"Marcus Müller" <marcus_zsh@hostalia.de>,
zsh-workers@zsh.org
Subject: Re: [Bug] modules zsh/tcp, zsh/zftp unloadable, probably affecting most modern Linuxes
Date: Mon, 5 Jun 2023 21:35:42 +0200 [thread overview]
Message-ID: <227fe72b-7441-935c-55a7-421945da54b3@hostalia.de> (raw)
In-Reply-To: <027f2a491b638e2ffaf7766fe4adf29537c11fdf.camel@fifi.org>
Hi Phil,
thanks for the follow-up:
On 6/4/23 23:17, Philippe Troin wrote:
> Interestingly:
> % zsh -f
> % echo $ZSH_VERSION
> 5.9
> % rpm -q zsh
> zsh-5.9-5.fc38.x86_64
> % zmodload zsh/zftp
> zsh: failed to load module `zsh/zftp': /usr/lib64/zsh/5.9/zsh/zftp.so: undefined symbol: freehostent
> % autoload zfinit
> % zfinit
> % zmodload zsh/zftp
ah, ok, that's how it's supposed to work? Shouldn't the module then not
trigger some warning or specific error on load, before the dynamic
loader runs and fails?
> freehostent is defined in zsh/net/tcp:
>
> % nm --dynamic /usr/lib64/zsh/5.9/zsh/net/tcp.so| grep freehostent
> 00000000000027c0 T freehostent
Hui. Looking into tcp.c:197, that function is
---
/**/
mod_export void
freehostent(UNUSED(struct hostent *ptr))
{
}
---
Why is that not calling `free`? Oh, very simple, because above, the
comment near the getipnodebyname implementation says:
---
/* note: this is not a complete implementation. If ignores the flags,
and does not provide the memory allocation of the standard interface.
Each returned structure will overwrite the previous one. */
---
Ah, so we're exporting and thus overwriting a symbol that overwrites a
pointer by the name of an existing libc function with a "overrides
potentially unowned memory" one?
That sounds a tad undesirable in the grander scheme of things :)
Since the only use of this function pair (zsh_getipnodebyname,
freehostent) is to be used internally in zfinit'ed modules, and the
number of internal consumers is zftp.c, could I propose we just rename
`freehostent` to `zsh_freehostent`? That would sound less invasive, and
would at least send the next person not down the tracks looking for libc
anachronisms (not blaming anyone but me for going down that road) ;-)
> Since I think you're supposed to initialize zftp through zfinit, I do
> not think this qualifies as a bug.
Hm, yeah, surprising to me, but probably documented somewhere well enough.
> But the freehostent symbol in zsh/net/tcp.so feels a little funky.
I'd agree, see above
Cheers,
Marcus
next prev parent reply other threads:[~2023-06-05 19:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-04 13:51 Marcus Müller
2023-06-04 20:37 ` Marcus Müller
2023-06-04 21:17 ` Philippe Troin
2023-06-05 19:35 ` Marcus Müller [this message]
2023-06-05 20:07 ` Bart Schaefer
2023-06-06 6:42 ` Jun T
2023-06-06 9:05 ` Peter Stephenson
2023-06-06 14:38 ` Jun. T
2023-06-06 15:01 ` Peter Stephenson
2023-06-06 16:37 ` Philippe Troin
2023-06-06 17:54 ` Mikael Magnusson
2023-06-07 2:05 ` Jun T
2023-06-07 2:35 ` Jun T
2023-06-07 14:40 ` Jun. T
2023-06-23 13:41 ` Jun. T
2023-06-07 9:25 ` Marcus Müller
2023-06-04 22:41 ` Axel Beckert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=227fe72b-7441-935c-55a7-421945da54b3@hostalia.de \
--to=marcus_zsh@hostalia.de \
--cc=phil@fifi.org \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).