# [PATCH] Fix an off by one bug in pretty.c

2 messages from 2008-01-05 to 2008-01-05. Participants: Marco Costalba.
Thread: https://gitlist.dev/t/11487

## Marco Costalba, 2008-01-05 22:55

Subject: [PATCH] Fix an off by one bug in pretty.c
Message-ID: <e5bfff550801051455i3d589c4q9375aeab0cb6aa47@mail.gmail.com>
URL: https://gitlist.dev/e/e5bfff550801051455i3d589c4q9375aeab0cb6aa47%40mail.gmail.com

```
In case author email is <> then we have the following
bug in function 'format_person_part'

/* parse name */
for (end = 0; end < len && msg[end] != '<'; end++)
       ; /* do nothing */

start = end + 1; /* now start points to '>' */

-- cut ---

/* parse email */
for (end = start + 1; end < len && msg[end] != '>'; end++)

And here 'end' is initialized with 'start + 1'
instead of 'start'. This turns out in empty commit
date when git log is used with --pretty=format option.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
---
 pretty.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pretty.c b/pretty.c
index 5b1078b..0b2f187 100644
--- a/pretty.c
+++ b/pretty.c
@@ -292,7 +292,7 @@ static void format_person_part
 	/* parse name */
 	for (end = 0; end < len && msg[end] != '<'; end++)
 		; /* do nothing */
-	start = end + 1;
+	start = end;
 	while (end > 0 && isspace(msg[end - 1]))
 		end--;
 	if (part == 'n') {	/* name */
-- 
1.5.4.rc2.38.gd6da3-dirty

```

## Marco Costalba, 2008-01-05 23:18

Subject: Re: [PATCH] Fix an off by one bug in pretty.c
Message-ID: <e5bfff550801051518u49e9c21ake36584457f4c9488@mail.gmail.com>
URL: https://gitlist.dev/e/e5bfff550801051518u49e9c21ake36584457f4c9488%40mail.gmail.com
In-Reply-To: <e5bfff550801051455i3d589c4q9375aeab0cb6aa47@mail.gmail.com>

```
On Jan 5, 2008 11:55 PM, Marco Costalba <mcostalba@gmail.com> wrote:
> In case author email is <> then we have the following
> bug in function 'format_person_part'
>

WARNING: Please discard previous patch!

Due to an error I sent the wrong one, the following is the correct one:

------------------- CUT ----------------------------------------------------


In case author email is <> then we have the following
bug in function 'format_person_part'

/* parse name */
for (end = 0; end < len && msg[end] != '<'; end++)
      ; /* do nothing */

start = end + 1; /* now start points to '>' */

-- cut ---

/* parse email */
for (end = start + 1; end < len && msg[end] != '>'; end++)

And here 'end' is initialized with 'start + 1'
instead of 'start'. This turns out in empty commit
date when git log is used with --pretty=format option.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
---

feba083ccd11374560e34a755ca03f07e7d45533
 pretty.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pretty.c b/pretty.c
index 5b1078b..3ce5e6f 100644
--- a/pretty.c
+++ b/pretty.c
@@ -304,7 +304,7 @@ static void format_person_part
 		return;

 	/* parse email */
-	for (end = start + 1; end < len && msg[end] != '>'; end++)
+	for (end = start; end < len && msg[end] != '>'; end++)
 		; /* do nothing */

 	if (end >= len)

```
