Subject: Re: strange teapop process
To: None <netbsd-users@NetBSD.org>
From: Christian Biere <christianbiere@gmx.de>
List: netbsd-users
Date: 01/30/2004 06:38:31
--xJK8B5Wah2CMJs8h
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Antoine Jacoutot wrote:
> ps output of teapop looks like this:
> teapop dDhil:nNp:st:vu stdin is not a socket\r\n Mailbox already locked.

That looks strange, yes..
=20
> For now, everything seems to work ok, but I'm a little bit concern about =
this
> strange output.

I'd be as well.

> On teapop mailling list, they said it might be a problem with
> NetBSD and getopt().

Or maybe just the wrong moon-phase?

> Anyone seeing this behaviour ?

I haven't compiled it, but by looking at the sources it's almost trivial
to tell that they're doing a couple of things the wrong way.

Why don't they try the following:
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
  char *s[] =3D { "I", " don't", " know", " what", " I'm", " doing!" };

  (void) argc;
  argv[0] =3D s[0];
  pause();
  return 0;
}

Run it with "./blah Am I stupid or what?" and look at the output of ps.
You might also kindly ask them WTF they're trying to do here:

=46rom pop_socket.c:
pop_socket_send(FILE * fd, const char *fmt, ...)
[...]
{
	char buf[512];

	va_list ap;
#if __STDC__
	va_start(ap, fmt);
#else
	va_start(ap);
#endif
	vsnprintf(buf, 508, fmt, ap);
	if (!(buf[strlen(buf - 2)] =3D=3D '\r' && buf[strlen(buf - 1)] =3D=3D '\n'=
))
		strcat(buf, "\r\n");
	va_end(ap);
[...]

There are at least 5 bugs plus a don't-do-this in this piece of code. Sorry,
in case your eyes are bleeding now.

--=20
Christian

--xJK8B5Wah2CMJs8h
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (NetBSD)

iD8DBQFAGe3X0KQix3oyIMcRAvp5AKDJNNePX9+lZ9mY/RNqFeeDgbP96wCfS8yJ
ju90IPMfVuaIrpVE9HnLeQA=
=mLDD
-----END PGP SIGNATURE-----

--xJK8B5Wah2CMJs8h--