]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - misc-utils/mcookie.c
Merge branch 'uuidv7' of https://github.com/t-8ch/util-linux
[thirdparty/util-linux.git] / misc-utils / mcookie.c
index 315740127e1598fbb1aa06bc6d50468ac294d465..99df4f4a6d973d8dad5b102553fe3da3088b8693 100644 (file)
@@ -1,4 +1,8 @@
-/* mcookie.c -- Generates random numbers for xauth
+/*
+ * No copyright is claimed.  This code is in the public domain; do with
+ * it what you wish.
+ *
+ * mcookie.c -- Generates random numbers for xauth
  * Created: Fri Feb  3 10:42:48 1995 by faith@cs.unc.edu
  * Revised: Fri Mar 19 07:48:01 1999 by faith@acm.org
  * Public Domain 1995, 1999 Rickard E. Faith (faith@acm.org)
@@ -65,7 +69,7 @@ static uint64_t hash_file(struct mcookie_control *ctl, int fd)
                        rdsz = wanted - count;
 
                r = read_all(fd, (char *) buf, rdsz);
-               if (r < 0)
+               if (r <= 0)
                        break;
                ul_MD5Update(&ctl->ctx, buf, r);
                count += r;
@@ -91,12 +95,12 @@ static void __attribute__((__noreturn__)) usage(void)
        fputs(_(" -v, --verbose         explain what is being done\n"), out);
 
        fputs(USAGE_SEPARATOR, out);
-       printf(USAGE_HELP_OPTIONS(23));
+       fprintf(out, USAGE_HELP_OPTIONS(23));
 
        fputs(USAGE_ARGUMENTS, out);
-       printf(USAGE_ARG_SIZE(_("<num>")));
+       fprintf(out, USAGE_ARG_SIZE(_("<num>")));
 
-       printf(USAGE_MAN_TAIL("mcookie(1)"));
+       fprintf(out, USAGE_MAN_TAIL("mcookie(1)"));
 
        exit(EXIT_SUCCESS);
 }