diff --git a/test/zdtm/static/binfmt_misc.c b/test/zdtm/static/binfmt_misc.c index 036eb9fe9..4863659c5 100644 --- a/test/zdtm/static/binfmt_misc.c +++ b/test/zdtm/static/binfmt_misc.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -30,7 +31,7 @@ void create_magic_pattern(char *buf, const char *name) { int i, magic, mask, offset; - magic = rand() % (MAX_MAGIC + 1); + magic = rand() % MAX_MAGIC + 1; mask = (rand() % 2) ? magic : 0; offset = MAX_MAGIC_OFFSET - magic; offset = rand() % (offset + 1); @@ -52,11 +53,11 @@ void create_extension_pattern(char *buf, const char *name) { int i, extension; - extension = rand() % (MAX_EXTENSION + 1); + extension = rand() % MAX_EXTENSION + 1; buf += sprintf(buf, ":%s:E::", name); for (i = 0; i < extension; i++) { - int c = rand(); + int c = rand() % 256; if (c == '\0' || c == ':' || c == '\n' || c == '/') c = '1'; @@ -102,6 +103,8 @@ int main(int argc, char **argv) char *dump[2]; int i, fd, len; + srand(time(NULL)); + test_init(argc, argv); snprintf(NAME[0], PATH_MAX, "%s_magic", filename);