summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlteo <lteo@openbsd.org>2013-03-30 02:42:24 +0000
committerlteo <lteo@openbsd.org>2013-03-30 02:42:24 +0000
commit005e4596c56f2c21e7fb1232fce1fb695e4ade56 (patch)
tree7aa825499f22c7d7ed48362f658057b761ccfc2c
parentProvide a default discipline interrupt handling function and migrate all of (diff)
downloadwireguard-openbsd-005e4596c56f2c21e7fb1232fce1fb695e4ade56.tar.xz
wireguard-openbsd-005e4596c56f2c21e7fb1232fce1fb695e4ade56.zip
Return an exit code of 1 if the file cannot be opened (e.g. file does
not exist), or if there is an error reading the file stream. From Patrik Lundin, thanks! ok deraadt
-rw-r--r--bin/md5/md5.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/bin/md5/md5.c b/bin/md5/md5.c
index af0f1748aa0..6382949362a 100644
--- a/bin/md5/md5.c
+++ b/bin/md5/md5.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: md5.c,v 1.54 2012/12/04 02:38:51 deraadt Exp $ */
+/* $OpenBSD: md5.c,v 1.55 2013/03/30 02:42:24 lteo Exp $ */
/*
* Copyright (c) 2001,2003,2005-2006 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -194,7 +194,7 @@ struct hash_function {
TAILQ_HEAD(hash_list, hash_function);
void digest_end(const struct hash_function *, void *, char *, size_t, int);
-void digest_file(const char *, struct hash_list *, int);
+int digest_file(const char *, struct hash_list *, int);
int digest_filelist(const char *, struct hash_function *);
void digest_print(const struct hash_function *, const char *, const char *);
void digest_printstr(const struct hash_function *, const char *, const char *);
@@ -386,10 +386,10 @@ main(int argc, char **argv)
error += digest_filelist(*argv++,
TAILQ_FIRST(&hl));
} else if (pflag || argc == 0)
- digest_file("-", &hl, pflag);
+ error = digest_file("-", &hl, pflag);
else
while (argc--)
- digest_file(*argv++, &hl, 0);
+ error += digest_file(*argv++, &hl, 0);
return(error ? EXIT_FAILURE : EXIT_SUCCESS);
}
@@ -476,7 +476,7 @@ digest_printstr(const struct hash_function *hf, const char *what,
}
}
-void
+int
digest_file(const char *file, struct hash_list *hl, int echo)
{
struct hash_function *hf;
@@ -489,7 +489,7 @@ digest_file(const char *file, struct hash_list *hl, int echo)
fp = stdin;
else if ((fp = fopen(file, "r")) == NULL) {
warn("cannot open %s", file);
- return;
+ return(1);
}
if (echo)
@@ -510,7 +510,7 @@ digest_file(const char *file, struct hash_list *hl, int echo)
warn("%s: read error", file);
if (fp != stdin)
fclose(fp);
- return;
+ return(1);
}
if (fp != stdin)
fclose(fp);
@@ -523,6 +523,7 @@ digest_file(const char *file, struct hash_list *hl, int echo)
else
digest_print(hf, file, digest);
}
+ return(0);
}
/*