# [GUILT] [PATCH] Fix fatal "guilt graph" error in sha1sum invocation.

6 messages from 2012-03-14 to 2012-03-15. Participants: Per Cederqvist, Jeff Sipek, Andreas Schwab, John Szakmeister.
Thread: https://gitlist.dev/t/29946

## Per Cederqvist, 2012-03-14 13:34

Subject: [GUILT] [PATCH] Fix fatal "guilt graph" error in sha1sum invocation.
Message-ID: <87399bpaq9.fsf@opera.com>
URL: https://gitlist.dev/e/87399bpaq9.fsf%40opera.com

```
Fix the compatibility function sha1 so that it reads from
stdin (and not a file with a zero-length file name) when
no argument is supplied.

Signed-off-by: Per Cederqvist <cederp@opera.com>
---
 os.Darwin |    7 ++++++-
 os.Linux  |    7 ++++++-
 os.SunOS  |    7 ++++++-
 3 files changed, 18 insertions(+), 3 deletions(-)

Note: I have tested both versions of the sha1 function, but only on
Linux as I don't have access to a Mac.

    /ceder

diff --git a/os.Darwin b/os.Darwin
index 470f5fb..acf6b68 100644
--- a/os.Darwin
+++ b/os.Darwin
@@ -27,7 +27,12 @@ head_n()
 # usage: sha1 [file]
 sha1()
 {
-	openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2  \1,"
+	if [ $# = 1 ]
+	then
+		openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2  \1,"
+	else
+		openssl dgst -sha1 | sed 's,$,  -,'
+	fi
 }
 
 # usage: cp_a <src> <dst>
diff --git a/os.Linux b/os.Linux
index 30b9cb0..aaebf88 100644
--- a/os.Linux
+++ b/os.Linux
@@ -30,7 +30,12 @@ head_n()
 # usage: sha1 [file]
 sha1()
 {
-	sha1sum "$1"
+	if [ $# = 1 ]
+	then
+		sha1sum "$1"
+	else
+		sha1sum
+	fi
 }
 
 # usage: cp_a <src> <dst>
diff --git a/os.SunOS b/os.SunOS
index 30b9cb0..aaebf88 100644
--- a/os.SunOS
+++ b/os.SunOS
@@ -30,7 +30,12 @@ head_n()
 # usage: sha1 [file]
 sha1()
 {
-	sha1sum "$1"
+	if [ $# = 1 ]
+	then
+		sha1sum "$1"
+	else
+		sha1sum
+	fi
 }
 
 # usage: cp_a <src> <dst>
-- 
1.7.9

```

## Jeff Sipek, 2012-03-14 14:21

Subject: Re: [GUILT] [PATCH] Fix fatal "guilt graph" error in sha1sum invocation.
Message-ID: <20120314142144.GB12588@poseidon.cudanet.local>
URL: https://gitlist.dev/e/20120314142144.GB12588%40poseidon.cudanet.local
In-Reply-To: <87399bpaq9.fsf@opera.com>

```
On Wed, Mar 14, 2012 at 02:34:38PM +0100, Per Cederqvist wrote:
> Fix the compatibility function sha1 so that it reads from
> stdin (and not a file with a zero-length file name) when
> no argument is supplied.

I just ran into this yesterday.  I stupidly changed the caller of sha1 to
pass in - for the filename.  That worked for me since I ended up using the
sha1sum implementations; openssl is not happy about that.  So, your patch
looks good.

Now, I should actually figure out how to get the git repo out there again.

Thanks,

Jeff.

> Signed-off-by: Per Cederqvist <cederp@opera.com>
> ---
>  os.Darwin |    7 ++++++-
>  os.Linux  |    7 ++++++-
>  os.SunOS  |    7 ++++++-
>  3 files changed, 18 insertions(+), 3 deletions(-)
> 
> Note: I have tested both versions of the sha1 function, but only on
> Linux as I don't have access to a Mac.
> 
>     /ceder
> 
> diff --git a/os.Darwin b/os.Darwin
> index 470f5fb..acf6b68 100644
> --- a/os.Darwin
> +++ b/os.Darwin
> @@ -27,7 +27,12 @@ head_n()
>  # usage: sha1 [file]
>  sha1()
>  {
> -	openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2  \1,"
> +	if [ $# = 1 ]
> +	then
> +		openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2  \1,"
> +	else
> +		openssl dgst -sha1 | sed 's,$,  -,'
> +	fi
>  }
>  
>  # usage: cp_a <src> <dst>
> diff --git a/os.Linux b/os.Linux
> index 30b9cb0..aaebf88 100644
> --- a/os.Linux
> +++ b/os.Linux
> @@ -30,7 +30,12 @@ head_n()
>  # usage: sha1 [file]
>  sha1()
>  {
> -	sha1sum "$1"
> +	if [ $# = 1 ]
> +	then
> +		sha1sum "$1"
> +	else
> +		sha1sum
> +	fi
>  }
>  
>  # usage: cp_a <src> <dst>
> diff --git a/os.SunOS b/os.SunOS
> index 30b9cb0..aaebf88 100644
> --- a/os.SunOS
> +++ b/os.SunOS
> @@ -30,7 +30,12 @@ head_n()
>  # usage: sha1 [file]
>  sha1()
>  {
> -	sha1sum "$1"
> +	if [ $# = 1 ]
> +	then
> +		sha1sum "$1"
> +	else
> +		sha1sum
> +	fi
>  }
>  
>  # usage: cp_a <src> <dst>
> -- 
> 1.7.9
> 

-- 
Only two things are infinite, the universe and human stupidity, and I'm not
sure about the former.
		- Albert Einstein

```

## Andreas Schwab, 2012-03-14 14:27

Subject: Re: [GUILT] [PATCH] Fix fatal "guilt graph" error in sha1sum invocation.
Message-ID: <m2k42nmf5g.fsf@igel.home>
URL: https://gitlist.dev/e/m2k42nmf5g.fsf%40igel.home
In-Reply-To: <87399bpaq9.fsf@opera.com>

```
Per Cederqvist <cederp@opera.com> writes:

> -	openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2  \1,"
> +	if [ $# = 1 ]
> +	then
> +		openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2  \1,"
> +	else
> +		openssl dgst -sha1 | sed 's,$,  -,'

$ openssl dgst -sha1 </dev/null
(stdin)= da39a3ee5e6b4b0d3255bfef95601890afd80709

>  # usage: sha1 [file]
>  sha1()
>  {
> -	sha1sum "$1"
> +	if [ $# = 1 ]
> +	then
> +		sha1sum "$1"
> +	else
> +		sha1sum
> +	fi

        sha1sum "$@"

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

```

## Per Cederqvist, 2012-03-15 08:42

Subject: Re: [GUILT] [PATCH] Fix fatal "guilt graph" error in sha1sum invocation.
Message-ID: <4F61AB63.5040304@opera.com>
URL: https://gitlist.dev/e/4F61AB63.5040304%40opera.com
In-Reply-To: <m2k42nmf5g.fsf@igel.home>

```
On 03/14/2012 03:27 PM, Andreas Schwab wrote:

> Per Cederqvist<cederp@opera.com>  writes:
>
>> -	openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2  \1,"
>> +	if [ $# = 1 ]
>> +	then
>> +		openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2  \1,"
>> +	else
>> +		openssl dgst -sha1 | sed 's,$,  -,'
>
> $ openssl dgst -sha1</dev/null
> (stdin)= da39a3ee5e6b4b0d3255bfef95601890afd80709

Was that on a Darwin? If so, my fix obviously needs some
work on that platform. I tested openssl-0.9.8o on Ubuntu
11.04, and here it looks like this:

$ openssl dgst -sha1</dev/null
da39a3ee5e6b4b0d3255bfef95601890afd80709
$ openssl version
OpenSSL 0.9.8o 01 Jun 2010

     /ceder

>>   # usage: sha1 [file]
>>   sha1()
>>   {
>> -	sha1sum "$1"
>> +	if [ $# = 1 ]
>> +	then
>> +		sha1sum "$1"
>> +	else
>> +		sha1sum
>> +	fi
>
>          sha1sum "$@"
>
> Andreas.
>

```

## Andreas Schwab, 2012-03-15 09:49

Subject: Re: [GUILT] [PATCH] Fix fatal "guilt graph" error in sha1sum invocation.
Message-ID: <m2haxqjirr.fsf@igel.home>
URL: https://gitlist.dev/e/m2haxqjirr.fsf%40igel.home
In-Reply-To: <4F61AB63.5040304@opera.com>

```
Per Cederqvist <cederp@opera.com> writes:

> On 03/14/2012 03:27 PM, Andreas Schwab wrote:
>
>> Per Cederqvist<cederp@opera.com>  writes:
>>
>>> -	openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2  \1,"
>>> +	if [ $# = 1 ]
>>> +	then
>>> +		openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2  \1,"
>>> +	else
>>> +		openssl dgst -sha1 | sed 's,$,  -,'
>>
>> $ openssl dgst -sha1</dev/null
>> (stdin)= da39a3ee5e6b4b0d3255bfef95601890afd80709
>
> Was that on a Darwin?

No.

$ openssl version
OpenSSL 1.0.0e 6 Sep 2011

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

```

## John Szakmeister, 2012-03-15 09:56

Subject: Re: [GUILT] [PATCH] Fix fatal "guilt graph" error in sha1sum invocation.
Message-ID: <CAEBDL5XHZ-ca+wX91GrYu5T_rZ76pyrtPuzjWtVRtXg-MWSygQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAEBDL5XHZ-ca%2BwX91GrYu5T_rZ76pyrtPuzjWtVRtXg-MWSygQ%40mail.gmail.com
In-Reply-To: <4F61AB63.5040304@opera.com>

```
On Thu, Mar 15, 2012 at 4:42 AM, Per Cederqvist <cederp@opera.com> wrote:
> On 03/14/2012 03:27 PM, Andreas Schwab wrote:
>
>> Per Cederqvist<cederp@opera.com>  writes:
>>
>>> -       openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2  \1,"
>>> +       if [ $# = 1 ]
>>> +       then
>>> +               openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2
>>>  \1,"
>>> +       else
>>> +               openssl dgst -sha1 | sed 's,$,  -,'
>>
>>
>> $ openssl dgst -sha1</dev/null
>> (stdin)= da39a3ee5e6b4b0d3255bfef95601890afd80709
>
>
> Was that on a Darwin?

Here's the output from my Mac (running Snow Leopard):

$ openssl dgst -sha1</dev/null
(stdin)= da39a3ee5e6b4b0d3255bfef95601890afd80709
$ openssl version
OpenSSL 1.0.0d 8 Feb 2011

-John

```
