aboutsummaryrefslogtreecommitdiff
path: root/crypt.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypt.c')
-rw-r--r--crypt.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/crypt.c b/crypt.c
index 3ebcbb3..86e8fce 100644
--- a/crypt.c
+++ b/crypt.c
@@ -1,4 +1,5 @@
#define _XOPEN_SOURCE
+#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -11,7 +12,7 @@ void usage(FILE *, int);
int main (int argc, char **argv)
{
const char *hash, *key, *salt;
- int opt;
+ int opt, printed;
while ((opt = getopt(argc, argv, "h")) != -1) {
switch (opt) {
@@ -44,8 +45,16 @@ int main (int argc, char **argv)
if (!(hash = crypt(key, salt))) {
error(strerror(errno));
}
+ assert(strlen(hash) > 0);
+
+ /*
+ * Print the hash, and ensure we printed all of it
+ */
+ if ((printed = printf("%s\n", hash)) < 0) {
+ error(strerror(errno));
+ }
+ assert(printed == strlen(hash) + 1);
- puts(hash);
exit(EXIT_SUCCESS);
}