File sha1collisiondetection-1.0.3-io-fixes.patch of Package sha1collisiondetection
From: Andreas Stieger <astieger@suse.com>
Date: Mon, 8 May 2017 21:51:28 +0200
Subject: some IO improvements
References: https://github.com/cr-marcstevens/sha1collisiondetection/pull/28
---
src/main.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Index: sha1collisiondetection-stable-v1.0.3/src/main.c
===================================================================
--- sha1collisiondetection-stable-v1.0.3.orig/src/main.c 2017-05-22 18:17:51.339889238 +0200
+++ sha1collisiondetection-stable-v1.0.3/src/main.c 2017-05-22 18:18:14.471988044 +0200
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include <libgen.h>
#include "sha1.h"
@@ -23,7 +24,7 @@ int main(int argc, char** argv)
if (argc < 2)
{
- printf("Usage: %s <file>\n", basename(argv[0]));
+ fprintf(stderr, "Usage: %s <file>\n", basename(argv[0]));
return 1;
}
@@ -37,10 +38,14 @@ int main(int argc, char** argv)
SHA1DCSetDetectReducedRoundCollision(&ctx2, 1);
}
- fd = fopen(argv[i], "rb");
+ if(!strcmp(argv[i],"-")) {
+ fd = stdin;
+ } else {
+ fd = fopen(argv[i], "rb");
+ }
if (fd == NULL)
{
- printf("cannot open file: %s\n", argv[i]);
+ fprintf(stderr, "cannot open file: %s: %s\n", argv[i], strerror(errno));
return 1;
}
@@ -53,12 +58,12 @@ int main(int argc, char** argv)
}
if (ferror(fd))
{
- printf("error while reading file: %s\n", argv[i]);
+ fprintf(stderr, "error while reading file: %s: %s\n", argv[i], strerror(errno));
return 1;
}
if (!feof(fd))
{
- printf("not end of file?: %s\n",argv[i]);
+ fprintf(stderr, "not end of file?: %s: %s\n", argv[i], strerror(errno));
return 1;
}
Index: sha1collisiondetection-stable-v1.0.3/README.md
===================================================================
--- sha1collisiondetection-stable-v1.0.3.orig/README.md 2017-05-22 18:17:51.339889238 +0200
+++ sha1collisiondetection-stable-v1.0.3/README.md 2017-05-22 18:17:54.539902741 +0200
@@ -51,6 +51,7 @@ Examples:
```
bin/sha1dcsum test/sha1_reducedsha_coll.bin test/shattered-1.pdf
bin/sha1dcsum_partialcoll test/sha1reducedsha_coll.bin test/shattered-1.pdf
+pipe_data | bin/sha1dcsum -
```
## Library usage