[tpop3d-discuss] problem with password containing spaces

Chris Lightfoot chris at ex-parrot.com
Mon, 29 Apr 2002 18:27:04 +0100


On Mon, Apr 29, 2002 at 07:12:20PM +0200, Tadas =DEelionis wrote:
> it makes sense to do so.
> currently i'm considering to go back to gnupopd+vmail, which is far fro=
m
> perfect too, or to patch tpop3d by myself, but it would take less time =
to
> do so for you i guess...

OK, try this (against 1.4.1):

diff -u -r1.31 connection.c
--- connection.c        2002/03/18 23:47:33     1.31
+++ connection.c        2002/04/29 17:26:04
@@ -248,9 +248,31 @@
  * Create a new pop3command object. */
 pop3command pop3command_new(const char *s) {
     pop3command p;
+    const char *q;
     int i;
    =20
-    p =3D xcalloc(1, sizeof *p);
+    p =3D xcalloc(sizeof *p, 1);
+
+    /* Ugly. PASS is a special case, because we permit a password to con=
tain
+     * spaces. */
+    q =3D s + strspn(s, " \t");
+    if (strncasecmp(q, "PASS ", 5) =3D=3D 0) {
+        /* Manual parsing. */
+        p->cmd =3D PASS;
+        p->toks =3D xcalloc(sizeof *p->toks, 1);
+       =20
+        p->toks->str =3D xstrdup(q);
+        chomp(p->toks->str);
+        p->toks->str[4] =3D 0;
+       =20
+        p->toks->toks =3D xcalloc(sizeof(char*), 2);
+        p->toks->toks[0] =3D p->toks->str;
+        p->toks->toks[1] =3D p->toks->str + 5;
+       =20
+        p->toks->num =3D 2;
+
+        return p;
+    }
=20
     p->cmd =3D UNKNOWN;
     p->toks =3D tokens_new(s, " \t");


--=20
``That Ariel Sharon. Boy, he sure is controversial.
  Most Western countries would have to have a military coup
  before they enjoyed a leader of that caliber.'' (Sydney Webb)