mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: patch: make the size of errbuf configurable
Date: Sun, 19 May 2013 20:21:19 -0400	[thread overview]
Message-ID: <20130520002119.GL20323@brightrain.aerifal.cx> (raw)
In-Reply-To: <5199699F.4050009@eservices.virginia.edu>

On Sun, May 19, 2013 at 08:09:03PM -0400, Z. Gilboa wrote:
> > From what I can see, complexity can be avoided and maybe even reduced
> >by refactoring the code so that all the places that set an error
> >message call a short simple function that wraps snprintf and allocates
> >a new buffer if needed. The complexity reduction would be if we can
> >eliminate duplicate logic at each call point, which I haven't checked
> >yet.
> >
> >Rich
> 
> When moving beyond dynlink.c then yes, I believe, that should be
> beneficial.  I just had a quick look at the places where snprintf is
> used, and found that the following functions might benefit from the
> above wrapper:

I was just looking at dynlink.c, but we could consider whether the
same issue applies in other places. I doubt the same function would be
useful in other places though since some of the logic I'd want to
factor would be dynlink-specific. Basically, I would want the function
to also encapsulate the dynlink error handling code (usually longjmp
or printing an error message).

> dynlink.c:    all functions that call snprintf
> syslog.c:    _vsyslog

Indeed there's a question of what syslog should do when the message is
too long. But unboundedly-long messages can't really be supported
anyway; the ultimate upper limit is the max unix socket datagram size.

> getnameinfo
> inet_ntop (unsure)

Not necessary. All strings here are highly bounded in size, and in
most (all?) places they're using caller-provided buffers anyway.

> sem_open (unsure: _name_ can be up to 251 characters long
> (http://man7.org/linux/man-pages/man7/sem_overview.7.html), but is
> link to _tmp_ which is only up to 64 characters long)

I'm not sure what you're saying here. All of the strings here are
highly bounded in size, as you noted. There's certainly no need for
dynamic allocation of the name buffer, which would introduce an
additional failure case.

Rich


  reply	other threads:[~2013-05-20  0:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-19 20:12 Z. Gilboa
2013-05-19 21:03 ` Rich Felker
2013-05-19 21:51   ` Z. Gilboa
2013-05-19 22:09     ` Rich Felker
2013-05-19 22:26       ` Z. Gilboa
2013-05-19 23:22         ` Rich Felker
2013-05-20  0:09           ` Z. Gilboa
2013-05-20  0:21             ` Rich Felker [this message]
2013-05-20  0:37               ` Z. Gilboa
2013-05-19 21:05 ` Szabolcs Nagy
2013-05-19 21:36   ` Luca Barbato
2013-05-19 21:48     ` Rich Felker

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=20130520002119.GL20323@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    /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/musl/

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).