Subject: Re: server bind failure 48: Address already in use
To: None <>
From: Christian Biere <>
List: current-users
Date: 04/05/2003 20:47:04
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Hi Thomas,

Caffeinate The World <> wrote:
> --- Christian Biere <> wrote:
> > Caffeinate The World <> wrote:
> > 
> > > /* defensive programming  */

The following is *not* defensive.

> > >           sprintf(txt,"Chat server bind failure %d: %s\n",errno,
> > > sys_errlist[errno]);

Sorry, I didn't realize that you wrote the program yourself.

> I would benefit much from your  experience if you could tell me what
> mistake I made.

sprintf() is a well-known source for buffer overflows. In your case,
truncation would hardly be a problem. Thus, you should either use
snprintf() or at least "%.100s" instead of "%s" (Replace 100 with the
actual buffer size). In the latter case you have to keep carefully track
of the buffer size or you use a cpp definition together with the
stringify feature. You should not try to build the format string during

This one might be of interest for you (ignore the L-word):


Content-Type: application/pgp-signature

Version: GnuPG v1.2.1 (NetBSD)