summaryrefslogtreecommitdiffstats
path: root/crypto/heimdal/kadmin/add-random-users.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/heimdal/kadmin/add-random-users.c')
-rw-r--r--crypto/heimdal/kadmin/add-random-users.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/crypto/heimdal/kadmin/add-random-users.c b/crypto/heimdal/kadmin/add-random-users.c
index ebd1149..b797143 100644
--- a/crypto/heimdal/kadmin/add-random-users.c
+++ b/crypto/heimdal/kadmin/add-random-users.c
@@ -33,7 +33,7 @@
#include "kadmin_locl.h"
-RCSID("$Id: add-random-users.c,v 1.6 2001/09/20 09:17:33 assar Exp $");
+RCSID("$Id: add-random-users.c 19213 2006-12-04 23:36:36Z lha $");
#define WORDS_FILENAME "/usr/share/dict/words"
@@ -57,8 +57,7 @@ read_words (const char *filename, char ***ret_w)
while (fgets (buf, sizeof(buf), f) != NULL) {
size_t len;
- if (buf[strlen (buf) - 1] == '\n')
- buf[strlen (buf) - 1] = '\0';
+ buf[strcspn(buf, "\r\n")] = '\0';
if (n >= alloc) {
alloc = max(alloc + 16, alloc * 2);
w = erealloc (w, alloc * sizeof(char **));
@@ -72,6 +71,8 @@ read_words (const char *filename, char ***ret_w)
w[n++] = wptr;
wptr += len + 1;
}
+ if (n == 0)
+ errx(1, "%s is an empty file, no words to try", filename);
*ret_w = w;
return n;
}
@@ -156,12 +157,12 @@ usage (int ret)
int
main(int argc, char **argv)
{
- int optind = 0;
+ int optidx = 0;
int n = NUSERS;
const char *filename = WORDS_FILENAME;
setprogname(argv[0]);
- if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &optind))
+ if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &optidx))
usage(1);
if (help_flag)
usage (0);
@@ -170,8 +171,8 @@ main(int argc, char **argv)
return 0;
}
srand (0);
- argc -= optind;
- argv += optind;
+ argc -= optidx;
+ argv += optidx;
if (argc > 0) {
if (argc > 1)
OpenPOWER on IntegriCloud