# [patch] fixup GECOS handling

16 messages from 2005-04-18 to 2005-04-25. Participants: Martin Schlemmer, David Woodhouse, Kyle Hayes, Petr Baudis, Andy Isaacson.
Thread: https://gitlist.dev/t/99

## Martin Schlemmer, 2005-04-18 10:36

Subject: [patch] fixup GECOS handling
Message-ID: <1113820589.16288.5.camel@nosferatu.lan>
URL: https://gitlist.dev/e/1113820589.16288.5.camel%40nosferatu.lan

```
Hi,

The gecos is delimited by ',' or ';', so we should only use whatever
before the first ',' or ';' for the full name, and not just strip those.
Also, a '.' may be valid in the full name (Foo B. Zooman) or email
(foo.zooman@bar.com).

Signed-off-by: Martin Schlemmer <azarah@gentoo.org>

commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c     2005-04-18 12:22:18.000000000 +0200
@@ -96,21 +96,6 @@
                if (!c)
                        break;
        }
-
-       /*
-        * Go back, and remove crud from the end: some people
-        * have commas etc in their gecos field
-        */
-       dst--;
-       while (--dst >= p) {
-               unsigned char c = *dst;
-               switch (c) {
-               case ',': case ';': case '.':
-                       *dst = 0;
-                       continue;
-               }
-               break;
-       }
 }

 static const char *month_names[] = {
@@ -313,6 +298,11 @@
        if (!pw)
                die("You don't exist. Go away!");
        realgecos = pw->pw_gecos;
+       /* The name is seperated from the room no., tel no, etc via [,;] */
+       if (strchr(realgecos, ','))
+               realgecos[strchr(realgecos, ',') - realgecos] = '\0';
+       else if (strchr(realgecos, ';'))
+               realgecos[strchr(realgecos, ';') - realgecos] = '\0';
        len = strlen(pw->pw_name);
        memcpy(realemail, pw->pw_name, len);
        realemail[len] = '@';


-- 
Martin Schlemmer



commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c	2005-04-18 12:22:18.000000000 +0200
@@ -96,21 +96,6 @@
 		if (!c)
 			break;
 	}
-
-	/*
-	 * Go back, and remove crud from the end: some people
-	 * have commas etc in their gecos field
-	 */
-	dst--;
-	while (--dst >= p) {
-		unsigned char c = *dst;
-		switch (c) {
-		case ',': case ';': case '.':
-			*dst = 0;
-			continue;
-		}
-		break;
-	}
 }
 
 static const char *month_names[] = {
@@ -313,6 +298,11 @@
 	if (!pw)
 		die("You don't exist. Go away!");
 	realgecos = pw->pw_gecos;
+	/* The name is seperated from the room no., tel no, etc via ',' or ';' */
+	if (strchr(realgecos, ','))
+		realgecos[strchr(realgecos, ',') - realgecos] = '\0';
+	else if (strchr(realgecos, ';'))
+		realgecos[strchr(realgecos, ';') - realgecos] = '\0';
 	len = strlen(pw->pw_name);
 	memcpy(realemail, pw->pw_name, len);
 	realemail[len] = '@';

```

## David Woodhouse, 2005-04-18 12:35

Subject: Re: [patch] fixup GECOS handling
Message-ID: <1113827713.5286.13.camel@localhost.localdomain>
URL: https://gitlist.dev/e/1113827713.5286.13.camel%40localhost.localdomain
In-Reply-To: <1113820589.16288.5.camel@nosferatu.lan>

```
On Mon, 2005-04-18 at 12:36 +0200, Martin Schlemmer wrote:
> realgecos[strchr(realgecos, ',') - realgecos] = '\0';

Er, *strchr(realgecos, ',') = 0; surely? Even if the compiler is clever
enough to optimise out the gratuitous addition and subtraction, that's
no real excuse for it.

-- 
dwmw2


```

## Martin Schlemmer, 2005-04-18 12:58

Subject: Re: [patch] fixup GECOS handling
Message-ID: <1113829100.16288.26.camel@nosferatu.lan>
URL: https://gitlist.dev/e/1113829100.16288.26.camel%40nosferatu.lan
In-Reply-To: <1113827713.5286.13.camel@localhost.localdomain>

```
On Mon, 2005-04-18 at 22:35 +1000, David Woodhouse wrote:
> On Mon, 2005-04-18 at 12:36 +0200, Martin Schlemmer wrote:
> > realgecos[strchr(realgecos, ',') - realgecos] = '\0';
> 
> Er, *strchr(realgecos, ',') = 0; surely? Even if the compiler is clever
> enough to optimise out the gratuitous addition and subtraction, that's
> no real excuse for it.
> 

Err, right.  Updated patch.

The gecos is delimited by ',' or ';', so we should only use whatever
before the first ',' or ';' for the full name, and not just strip those.

Signed-off-by: Martin Schlemmer <azarah@gentoo.org>

commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c     2005-04-18 12:22:18.000000000 +0200
@@ -96,21 +96,6 @@
                if (!c)
                        break;
        }
-
-       /*
-        * Go back, and remove crud from the end: some people
-        * have commas etc in their gecos field
-        */
-       dst--;
-       while (--dst >= p) {
-               unsigned char c = *dst;
-               switch (c) {
-               case ',': case ';': case '.':
-                       *dst = 0;
-                       continue;
-               }
-               break;
-       }
 }

 static const char *month_names[] = {
@@ -313,6 +298,11 @@
        if (!pw)
                die("You don't exist. Go away!");
        realgecos = pw->pw_gecos;
+       /* The name is seperated from the room no., tel no, etc via [,;] */
+       if (strchr(realgecos, ','))
+               *strchr(realgecos, ',') = 0;
+       else if (strchr(realgecos, ';'))
+               *strchr(realgecos, ';') = 0;
        len = strlen(pw->pw_name);
        memcpy(realemail, pw->pw_name, len);
        realemail[len] = '@';


-- 
Martin Schlemmer



commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c	2005-04-18 12:22:18.000000000 +0200
@@ -96,21 +96,6 @@
 		if (!c)
 			break;
 	}
-
-	/*
-	 * Go back, and remove crud from the end: some people
-	 * have commas etc in their gecos field
-	 */
-	dst--;
-	while (--dst >= p) {
-		unsigned char c = *dst;
-		switch (c) {
-		case ',': case ';': case '.':
-			*dst = 0;
-			continue;
-		}
-		break;
-	}
 }
 
 static const char *month_names[] = {
@@ -313,6 +298,11 @@
 	if (!pw)
 		die("You don't exist. Go away!");
 	realgecos = pw->pw_gecos;
+	/* The name is seperated from the room no., tel no, etc via ',' or ';' */
+	if (strchr(realgecos, ','))
+		*strchr(realgecos, ',') = 0;
+	else if (strchr(realgecos, ';'))
+		*strchr(realgecos, ';') = 0;
 	len = strlen(pw->pw_name);
 	memcpy(realemail, pw->pw_name, len);
 	realemail[len] = '@';

```

## Martin Schlemmer, 2005-04-22 14:23

Subject: [patch] fixup GECOS handling
Message-ID: <1114179795.29271.18.camel@nosferatu.lan>
URL: https://gitlist.dev/e/1114179795.29271.18.camel%40nosferatu.lan
In-Reply-To: <1113827713.5286.13.camel@localhost.localdomain>

```
Hi,

This still applies - any reason for not doing this?


Thanks,

----

The GECOS is delimited by ',' or ';', so we should only use whatever is
before the first ',' or ';' for the full name, rather than just
stripping those.

Signed-off-by: Martin Schlemmer <azarah@gentoo.org>

commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c     2005-04-18 12:22:18.000000000 +0200
@@ -96,21 +96,6 @@
                if (!c)
                        break;
        }
-
-       /*
-        * Go back, and remove crud from the end: some people
-        * have commas etc in their gecos field
-        */
-       dst--;
-       while (--dst >= p) {
-               unsigned char c = *dst;
-               switch (c) {
-               case ',': case ';': case '.':
-                       *dst = 0;
-                       continue;
-               }
-               break;
-       }
 }

 static const char *month_names[] = {
@@ -313,6 +298,11 @@
        if (!pw)
                die("You don't exist. Go away!");
        realgecos = pw->pw_gecos;
+       /* The name is seperated from the room no., tel no, etc via [,;] */
+       if (strchr(realgecos, ','))
+               *strchr(realgecos, ',') = 0;
+       else if (strchr(realgecos, ';'))
+               *strchr(realgecos, ';') = 0;
        len = strlen(pw->pw_name);
        memcpy(realemail, pw->pw_name, len);
        realemail[len] = '@';



-- 
Martin Schlemmer



commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c	2005-04-18 12:22:18.000000000 +0200
@@ -96,21 +96,6 @@
 		if (!c)
 			break;
 	}
-
-	/*
-	 * Go back, and remove crud from the end: some people
-	 * have commas etc in their gecos field
-	 */
-	dst--;
-	while (--dst >= p) {
-		unsigned char c = *dst;
-		switch (c) {
-		case ',': case ';': case '.':
-			*dst = 0;
-			continue;
-		}
-		break;
-	}
 }
 
 static const char *month_names[] = {
@@ -313,6 +298,11 @@
 	if (!pw)
 		die("You don't exist. Go away!");
 	realgecos = pw->pw_gecos;
+	/* The name is seperated from the room no., tel no, etc via ',' or ';' */
+	if (strchr(realgecos, ','))
+		*strchr(realgecos, ',') = 0;
+	else if (strchr(realgecos, ';'))
+		*strchr(realgecos, ';') = 0;
 	len = strlen(pw->pw_name);
 	memcpy(realemail, pw->pw_name, len);
 	realemail[len] = '@';

```

## Kyle Hayes, 2005-04-22 16:16

Subject: Re: [patch] fixup GECOS handling
Message-ID: <1114186599.31076.409.camel@axer.marchex.com>
URL: https://gitlist.dev/e/1114186599.31076.409.camel%40axer.marchex.com
In-Reply-To: <1114179795.29271.18.camel@nosferatu.lan>

```
On Fri, 2005-04-22 at 16:23 +0200, Martin Schlemmer wrote:
> Hi,
> 
> This still applies - any reason for not doing this?

Seems like this will break on certain kinds of data.  See below.

>         if (!pw)
>                 die("You don't exist. Go away!");
>         realgecos = pw->pw_gecos;
> +       /* The name is seperated from the room no., tel no, etc via [,;] */
> +       if (strchr(realgecos, ','))
> +               *strchr(realgecos, ',') = 0;
> +       else if (strchr(realgecos, ';'))
> +               *strchr(realgecos, ';') = 0;
>         len = strlen(pw->pw_name);
>         memcpy(realemail, pw->pw_name, len);
>         realemail[len] = '@';

Suppose that the GECOS field is:

Hayes, Kyle; Room 42; 424-424-4242; foo bar baz...

You'll search for the first comma, find it, truncate my name to "Hayes",
and continue.

I have seen this kind of GECOS in larger environments where the
individual users are not the ones that administrate their machines.
Using the LastName, FirstName style of name is not rare. 

I think you want something like this (not tested):

char *comma,*semi;

comma = strchr(realgecos,',');
semi  = strchr(realgecos,';');

if(comma)
	if(semi)
		/* lastname, firstname; room #; phone # format */
		*semi  = 0;
	else
		*comma = 0;
else if(semi)
	*semi = 0;

(hopefully Evolution won't trash the indentation...)

Best,
Kyle

-- 
Kyle Hayes <kyle@marchex.com>
Marchex Inc.


```

## Martin Schlemmer, 2005-04-22 16:58

Subject: Re: [patch] fixup GECOS handling
Message-ID: <1114189105.29271.36.camel@nosferatu.lan>
URL: https://gitlist.dev/e/1114189105.29271.36.camel%40nosferatu.lan
In-Reply-To: <1114186599.31076.409.camel@axer.marchex.com>

```
On Fri, 2005-04-22 at 09:16 -0700, Kyle Hayes wrote:
> On Fri, 2005-04-22 at 16:23 +0200, Martin Schlemmer wrote:
> > Hi,
> > 
> > This still applies - any reason for not doing this?
> 
> Seems like this will break on certain kinds of data.  See below.
> 
> >         if (!pw)
> >                 die("You don't exist. Go away!");
> >         realgecos = pw->pw_gecos;
> > +       /* The name is seperated from the room no., tel no, etc via [,;] */
> > +       if (strchr(realgecos, ','))
> > +               *strchr(realgecos, ',') = 0;
> > +       else if (strchr(realgecos, ';'))
> > +               *strchr(realgecos, ';') = 0;
> >         len = strlen(pw->pw_name);
> >         memcpy(realemail, pw->pw_name, len);
> >         realemail[len] = '@';
> 
> Suppose that the GECOS field is:
> 
> Hayes, Kyle; Room 42; 424-424-4242; foo bar baz...
> 
> You'll search for the first comma, find it, truncate my name to "Hayes",
> and continue.
> 
> I have seen this kind of GECOS in larger environments where the
> individual users are not the ones that administrate their machines.
> Using the LastName, FirstName style of name is not rare. 
> 

What OS?  With Linux at least, this is what chfn's manpage say:

----
       The only restriction placed on the contents of the fields is that no control characters may  be  present,
       nor  any  of  comma, colon, or equal sign. The other field does not have this restriction, and is used to
       store accounting information used by other applications.
----

Meaning, if they use a ',' in one of the fields (and it is a linux
system with the chfn most probably from the shadow package), then they
are looking for trouble.  The only reason I added the ';' was because
somebody said whatever OS used it instead of a ','.


Thanks,

-- 
Martin Schlemmer


```

## Petr Baudis, 2005-04-22 17:18

Subject: Re: [patch] fixup GECOS handling
Message-ID: <20050422171818.GE7173@pasky.ji.cz>
URL: https://gitlist.dev/e/20050422171818.GE7173%40pasky.ji.cz
In-Reply-To: <1114189105.29271.36.camel@nosferatu.lan>

```
Dear diary, on Fri, Apr 22, 2005 at 06:58:25PM CEST, I got a letter
where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> Meaning, if they use a ',' in one of the fields (and it is a linux
> system with the chfn most probably from the shadow package), then they
> are looking for trouble.  The only reason I added the ';' was because
> somebody said whatever OS used it instead of a ','.

What about just swapping the two tests so that ; is cut off and , only
when no ; is around?

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

```

## Martin Schlemmer, 2005-04-22 17:25

Subject: Re: [patch] fixup GECOS handling
Message-ID: <1114190745.29271.39.camel@nosferatu.lan>
URL: https://gitlist.dev/e/1114190745.29271.39.camel%40nosferatu.lan
In-Reply-To: <20050422171818.GE7173@pasky.ji.cz>

```
On Fri, 2005-04-22 at 19:18 +0200, Petr Baudis wrote:
> Dear diary, on Fri, Apr 22, 2005 at 06:58:25PM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > Meaning, if they use a ',' in one of the fields (and it is a linux
> > system with the chfn most probably from the shadow package), then they
> > are looking for trouble.  The only reason I added the ';' was because
> > somebody said whatever OS used it instead of a ','.
> 
> What about just swapping the two tests so that ; is cut off and , only
> when no ; is around?
> 

Actually, maybe just leave it.  Its not a train smash, and in theory on
linux ';' is a valid char in the gecos.


-- 
Martin Schlemmer


```

## Kyle Hayes, 2005-04-22 17:43

Subject: Re: [patch] fixup GECOS handling
Message-ID: <1114191830.31076.426.camel@axer.marchex.com>
URL: https://gitlist.dev/e/1114191830.31076.426.camel%40axer.marchex.com
In-Reply-To: <1114189105.29271.36.camel@nosferatu.lan>

```
On Fri, 2005-04-22 at 18:58 +0200, Martin Schlemmer wrote:
> On Fri, 2005-04-22 at 09:16 -0700, Kyle Hayes wrote:
> > Suppose that the GECOS field is:
> > 
> > Hayes, Kyle; Room 42; 424-424-4242; foo bar baz...
> > 
> > You'll search for the first comma, find it, truncate my name to "Hayes",
> > and continue.
> > 
> > I have seen this kind of GECOS in larger environments where the
> > individual users are not the ones that administrate their machines.
> > Using the LastName, FirstName style of name is not rare. 
> > 
> 
> What OS?  With Linux at least, this is what chfn's manpage say:

Can't remember, it's been a while (years).  We had AIX, Solaris, Linux
and BSD machines at the time.  Might have been AIX, I think.  The memory
of which OS is vague, but not the annoyance of finding the problem :-(

> ----
>        The only restriction placed on the contents of the fields is that no control characters may  be  present,
>        nor  any  of  comma, colon, or equal sign. The other field does not have this restriction, and is used to
>        store accounting information used by other applications.
> ----
> 
> Meaning, if they use a ',' in one of the fields (and it is a linux
> system with the chfn most probably from the shadow package), then they
> are looking for trouble.  The only reason I added the ';' was because
> somebody said whatever OS used it instead of a ','.

>From the AIX version of chfn:

----
You can use any printable characters in the gecos information string
except a : (colon), which is an attribute delimiter.
----

The AIX examples show use of semicolon as a separator.

So, at least on AIX, it is appears valid to use the style I showed
above.  I don't have access to Solaris machines right now.  The BSD
(FreeBSD 4.11) version of man 5 passwd:

----
The gecos field normally contains comma (`,') separated subfields as
follows:...
----

Best,
Kyle

-- 
Kyle Hayes <kyle@marchex.com>
Marchex Inc.


```

## Kyle Hayes, 2005-04-22 17:58

Subject: Re: [patch] fixup GECOS handling
Message-ID: <1114192702.31076.428.camel@axer.marchex.com>
URL: https://gitlist.dev/e/1114192702.31076.428.camel%40axer.marchex.com
In-Reply-To: <20050422171818.GE7173@pasky.ji.cz>

```
On Fri, 2005-04-22 at 19:18 +0200, Petr Baudis wrote:
> Dear diary, on Fri, Apr 22, 2005 at 06:58:25PM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > Meaning, if they use a ',' in one of the fields (and it is a linux
> > system with the chfn most probably from the shadow package), then they
> > are looking for trouble.  The only reason I added the ';' was because
> > somebody said whatever OS used it instead of a ','.
> 
> What about just swapping the two tests so that ; is cut off and , only
> when no ; is around?

Even nicer.  I like it.  Very clean!

Best,
Kyle

-- 
Kyle Hayes <kyle@marchex.com>
Marchex Inc.


```

## Martin Schlemmer, 2005-04-22 19:06

Subject: Re: [patch] fixup GECOS handling
Message-ID: <1114196803.29271.52.camel@nosferatu.lan>
URL: https://gitlist.dev/e/1114196803.29271.52.camel%40nosferatu.lan
In-Reply-To: <1114192702.31076.428.camel@axer.marchex.com>

```
On Fri, 2005-04-22 at 10:58 -0700, Kyle Hayes wrote:
> On Fri, 2005-04-22 at 19:18 +0200, Petr Baudis wrote:
> > Dear diary, on Fri, Apr 22, 2005 at 06:58:25PM CEST, I got a letter
> > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > > Meaning, if they use a ',' in one of the fields (and it is a linux
> > > system with the chfn most probably from the shadow package), then they
> > > are looking for trouble.  The only reason I added the ';' was because
> > > somebody said whatever OS used it instead of a ','.
> > 
> > What about just swapping the two tests so that ; is cut off and , only
> > when no ; is around?
> 
> Even nicer.  I like it.  Very clean!
> 

Right, but ';' is not cutoff on linux for one, and from what you said
freebsd as well.  How about this rather (note that I assumed that the
use of ';' as delimiter will be in the minority, but we can switch
things around if it turns out the other way):

----
(not signed off, etc, as just for comments)

Index: commit-tree.c
===================================================================
--- 5f61aecb06c2f2579bbb5951b1b53e0dedc434eb/commit-tree.c  (mode:100644 sha1:c0b07f89286c3f6cceae8122b4c3142c8efaf8e1)
+++ uncommitted/commit-tree.c  (mode:100644)
@@ -96,21 +96,6 @@
                if (!c)
                        break;
        }
-
-       /*
-        * Go back, and remove crud from the end: some people
-        * have commas etc in their gecos field
-        */
-       dst--;
-       while (--dst >= p) {
-               unsigned char c = *dst;
-               switch (c) {
-               case ',': case ';': case '.':
-                       *dst = 0;
-                       continue;
-               }
-               break;
-       }
 }

 static const char *month_names[] = {
@@ -311,6 +296,17 @@
        if (!pw)
                die("You don't exist. Go away!");
        realgecos = pw->pw_gecos;
+       /*
+        * The GECOS fields are seperated via ',' on Linux, FreeBSD, etc,
+        * and ';' on AIX.
+        */
+#if defined(__aix__)
+       if (strchr(realgecos, ';'))
+               *strchr(realgecos, ';') = 0;
+#else
+       if (strchr(realgecos, ','))
+               *strchr(realgecos, ',') = 0;
+#endif
        len = strlen(pw->pw_name);
        memcpy(realemail, pw->pw_name, len);
        realemail[len] = '@';


-- 
Martin Schlemmer


```

## Kyle Hayes, 2005-04-22 20:46

Subject: Re: [patch] fixup GECOS handling
Message-ID: <1114202815.31076.444.camel@axer.marchex.com>
URL: https://gitlist.dev/e/1114202815.31076.444.camel%40axer.marchex.com
In-Reply-To: <1114196803.29271.52.camel@nosferatu.lan>

```
On Fri, 2005-04-22 at 21:06 +0200, Martin Schlemmer wrote:
> Right, but ';' is not cutoff on linux for one, and from what you said
> freebsd as well.  How about this rather (note that I assumed that the
> use of ';' as delimiter will be in the minority, but we can switch
> things around if it turns out the other way):

I'm not sure that __aix__ is defined, but it is close enough.  Someone
with an AIX compiler can correct it if needed.  Anyone know about HP-UX
and Tru64 and all those other ones?

Note that the original code also cuts on '.'.  Is that used by some *nix
in GECOS?

Best,
Kyle

> ----
> (not signed off, etc, as just for comments)
> 
> Index: commit-tree.c
> ===================================================================
> --- 5f61aecb06c2f2579bbb5951b1b53e0dedc434eb/commit-tree.c  (mode:100644 sha1:c0b07f89286c3f6cceae8122b4c3142c8efaf8e1)
> +++ uncommitted/commit-tree.c  (mode:100644)
> @@ -96,21 +96,6 @@
>                 if (!c)
>                         break;
>         }
> -
> -       /*
> -        * Go back, and remove crud from the end: some people
> -        * have commas etc in their gecos field
> -        */
> -       dst--;
> -       while (--dst >= p) {
> -               unsigned char c = *dst;
> -               switch (c) {
> -               case ',': case ';': case '.':
> -                       *dst = 0;
> -                       continue;
> -               }
> -               break;
> -       }
>  }
> 
>  static const char *month_names[] = {
> @@ -311,6 +296,17 @@
>         if (!pw)
>                 die("You don't exist. Go away!");
>         realgecos = pw->pw_gecos;
> +       /*
> +        * The GECOS fields are seperated via ',' on Linux, FreeBSD, etc,
> +        * and ';' on AIX.
> +        */
> +#if defined(__aix__)
> +       if (strchr(realgecos, ';'))
> +               *strchr(realgecos, ';') = 0;
> +#else
> +       if (strchr(realgecos, ','))
> +               *strchr(realgecos, ',') = 0;
> +#endif
>         len = strlen(pw->pw_name);
>         memcpy(realemail, pw->pw_name, len);
>         realemail[len] = '@';
> 
> 
-- 
Kyle Hayes <kyle@marchex.com>
Marchex Inc.


```

## Andy Isaacson, 2005-04-22 23:30

Subject: Re: [patch] fixup GECOS handling
Message-ID: <20050422233012.GA27638@hexapodia.org>
URL: https://gitlist.dev/e/20050422233012.GA27638%40hexapodia.org
In-Reply-To: <1114186599.31076.409.camel@axer.marchex.com>

```
On Fri, Apr 22, 2005 at 09:16:39AM -0700, Kyle Hayes wrote:
> if(comma)
> 	if(semi)
> 		/* lastname, firstname; room #; phone # format */
> 		*semi  = 0;
> 	else
> 		*comma = 0;
> else if(semi)
> 	*semi = 0;

That's a really complicated way of writing

if(semi) *semi = 0;
else if(comma) *comma = 0;

(The two code fragments are precisely identical.  Mmmm, strength
reduction.)

-andy

```

## Petr Baudis, 2005-04-23 23:38

Subject: Re: [patch] fixup GECOS handling
Message-ID: <20050423233821.GN13222@pasky.ji.cz>
URL: https://gitlist.dev/e/20050423233821.GN13222%40pasky.ji.cz
In-Reply-To: <1114196803.29271.52.camel@nosferatu.lan>

```
Dear diary, on Fri, Apr 22, 2005 at 09:06:43PM CEST, I got a letter
where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> @@ -311,6 +296,17 @@
>         if (!pw)
>                 die("You don't exist. Go away!");
>         realgecos = pw->pw_gecos;
> +       /*
> +        * The GECOS fields are seperated via ',' on Linux, FreeBSD, etc,
> +        * and ';' on AIX.
> +        */
> +#if defined(__aix__)
> +       if (strchr(realgecos, ';'))
> +               *strchr(realgecos, ';') = 0;
> +#else
> +       if (strchr(realgecos, ','))
> +               *strchr(realgecos, ',') = 0;
> +#endif
>         len = strlen(pw->pw_name);
>         memcpy(realemail, pw->pw_name, len);
>         realemail[len] = '@';

I'm confused, what does this has to do with AIX? Do we even have / can
expect to have any major AIX users?

I'm not too happy with this, I have to say. It seems it won't do always
the right thing anyway. I would still favour the approach when you cut
off everything after ';', and everything after ',' if no ';' is found.
Seems simplest, safest, etc.

Tell me about anyone who has a semicolon in his realname.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

```

## Martin Schlemmer, 2005-04-23 23:49

Subject: Re: [patch] fixup GECOS handling
Message-ID: <1114300156.27940.22.camel@nosferatu.lan>
URL: https://gitlist.dev/e/1114300156.27940.22.camel%40nosferatu.lan
In-Reply-To: <20050423233821.GN13222@pasky.ji.cz>

```
On Sun, 2005-04-24 at 01:38 +0200, Petr Baudis wrote:
> Dear diary, on Fri, Apr 22, 2005 at 09:06:43PM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > @@ -311,6 +296,17 @@
> >         if (!pw)
> >                 die("You don't exist. Go away!");
> >         realgecos = pw->pw_gecos;
> > +       /*
> > +        * The GECOS fields are seperated via ',' on Linux, FreeBSD, etc,
> > +        * and ';' on AIX.
> > +        */
> > +#if defined(__aix__)
> > +       if (strchr(realgecos, ';'))
> > +               *strchr(realgecos, ';') = 0;
> > +#else
> > +       if (strchr(realgecos, ','))
> > +               *strchr(realgecos, ',') = 0;
> > +#endif
> >         len = strlen(pw->pw_name);
> >         memcpy(realemail, pw->pw_name, len);
> >         realemail[len] = '@';
> 
> I'm confused, what does this has to do with AIX? Do we even have / can
> expect to have any major AIX users?
> 

Given.

> I'm not too happy with this, I have to say. It seems it won't do always
> the right thing anyway. I would still favour the approach when you cut
> off everything after ';', and everything after ',' if no ';' is found.
> Seems simplest, safest, etc.
> 
> Tell me about anyone who has a semicolon in his realname.
> 

Point I guess is still that the only valid delimiter on linux is ',',
and the only reason for the ';' was because of some aix/whatever user
saying that is a delimiter as well. But like I said: cat $this
> /dev/null ... This is basically the same type of discussion as the
hash collision one, and I'm sure we all have better things to do.


Thanks,

-- 
Martin Schlemmer


```

## Kyle Hayes, 2005-04-25 17:02

Subject: Re: [patch] fixup GECOS handling
Message-ID: <1114448538.13449.14.camel@axer.marchex.com>
URL: https://gitlist.dev/e/1114448538.13449.14.camel%40axer.marchex.com
In-Reply-To: <20050422233012.GA27638@hexapodia.org>

```
On Fri, 2005-04-22 at 16:30 -0700, Andy Isaacson wrote:
> On Fri, Apr 22, 2005 at 09:16:39AM -0700, Kyle Hayes wrote:
> > if(comma)
> > 	if(semi)
> > 		/* lastname, firstname; room #; phone # format */
> > 		*semi  = 0;
> > 	else
> > 		*comma = 0;
> > else if(semi)
> > 	*semi = 0;
> 
> That's a really complicated way of writing
> 
> if(semi) *semi = 0;
> else if(comma) *comma = 0;
> 
> (The two code fragments are precisely identical.  Mmmm, strength
> reduction.)

Indeed :-)

As someone else noted, this was too complex.  As another person noted,
this (like the SHA1 thread) has been thrashed around more than enough.

Best,
Kyle

-- 
Kyle Hayes <kyle@marchex.com>
Marchex Inc.


```
