test: several fixes in the testsuite.
This commit is contained in:
parent
53084c70a0
commit
08d023b37c
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* bug-div0 - program dividing by zero when fuzzed
|
||||
* Copyright (c) 2008 Sam Hocevar <sam@hocevar.net>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
*
|
||||
* This program is free software. It comes without any warranty, to
|
||||
* the extent permitted by applicable law. You can redistribute it
|
||||
* and/or modify it under the terms of the Do What The Fuck You Want
|
||||
* To Public License, Version 2, as published by Sam Hocevar. See
|
||||
* http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
* and/or modify it under the terms of the Do What the Fuck You Want
|
||||
* to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
* See http://www.wtfpl.net/ for more details.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@ -16,16 +16,17 @@
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
|
||||
int buf[1];
|
||||
volatile int buf[1];
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int ch;
|
||||
|
||||
while((ch = getc(stdin)) != EOF)
|
||||
while ((ch = getc(stdin)) != EOF)
|
||||
{
|
||||
buf[0] = 1 / !ch;
|
||||
if(ch) raise(SIGFPE); /* Needed on OS X... sigh. */
|
||||
if (ch)
|
||||
raise(SIGFPE); /* Needed on OS X... sigh. */
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* bug-memory - program exhausting the memory when fuzzed
|
||||
* Copyright (c) 2008 Sam Hocevar <sam@hocevar.net>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
*
|
||||
* This program is free software. It comes without any warranty, to
|
||||
* the extent permitted by applicable law. You can redistribute it
|
||||
* and/or modify it under the terms of the Do What The Fuck You Want
|
||||
* To Public License, Version 2, as published by Sam Hocevar. See
|
||||
* http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
* and/or modify it under the terms of the Do What the Fuck You Want
|
||||
* to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
* See http://www.wtfpl.net/ for more details.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@ -17,12 +17,12 @@
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i, ch;
|
||||
|
||||
while((ch = getc(stdin)) != EOF)
|
||||
int ch;
|
||||
while ((ch = getc(stdin)) != EOF)
|
||||
{
|
||||
char *tmp = malloc(1 + ch * 1024 * 1024);
|
||||
for(i = 0; i < 1024; i++)
|
||||
/* Mark as volatile to prevent the compiler from removing tmp */
|
||||
volatile char *tmp = malloc(1 + ch * 1024 * 1024);
|
||||
for (int i = 0; i < 1024; i++)
|
||||
tmp[ch * 1024 * i] = i;
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* bug-overflow - program causing a buffer overflow when fuzzed
|
||||
* Copyright (c) 2008 Sam Hocevar <sam@hocevar.net>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
*
|
||||
* This program is free software. It comes without any warranty, to
|
||||
* the extent permitted by applicable law. You can redistribute it
|
||||
* and/or modify it under the terms of the Do What The Fuck You Want
|
||||
* To Public License, Version 2, as published by Sam Hocevar. See
|
||||
* http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
* and/or modify it under the terms of the Do What the Fuck You Want
|
||||
* to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
* See http://www.wtfpl.net/ for more details.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@ -15,13 +15,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
char buf[1];
|
||||
volatile char buf[1];
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int ch;
|
||||
|
||||
while((ch = getc(stdin)) != EOF)
|
||||
while ((ch = getc(stdin)) != EOF)
|
||||
buf[ch * 1024 * 1024] = ch;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# check-div0 - check that zzuf can catch divisions by zero
|
||||
# Copyright (c) 2008-2010 Sam Hocevar <sam@hocevar.net>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
#
|
||||
# This program is free software. It comes without any warranty, to
|
||||
# the extent permitted by applicable law. You can redistribute it
|
||||
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
# and/or modify it under the terms of the Do What the Fuck You Want
|
||||
# to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
# See http://www.wtfpl.net/ for more details.
|
||||
#
|
||||
|
||||
. "$(dirname "$0")/functions.inc"
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# check-overflow - check that zzuf catches buffer overflows
|
||||
# Copyright (c) 2008-2010 Sam Hocevar <sam@hocevar.net>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
#
|
||||
# This program is free software. It comes without any warranty, to
|
||||
# the extent permitted by applicable law. You can redistribute it
|
||||
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
# and/or modify it under the terms of the Do What the Fuck You Want
|
||||
# to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
# See http://www.wtfpl.net/ for more details.
|
||||
#
|
||||
|
||||
. "$(dirname "$0")/functions.inc"
|
||||
|
||||
@ -1,8 +1,16 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# check-source - find tabs or trailing spaces in the source code
|
||||
#
|
||||
# Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
#
|
||||
# This program is free software. It comes without any warranty, to
|
||||
# the extent permitted by applicable law. You can redistribute it
|
||||
# and/or modify it under the terms of the Do What the Fuck You Want
|
||||
# to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
# See http://www.wtfpl.net/ for more details.
|
||||
#
|
||||
|
||||
#
|
||||
# Check that we have no tabs or trailing spaces in the source code
|
||||
#
|
||||
nfails=0
|
||||
nfiles=0
|
||||
nlines=0
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# check-utils - check that zzuf properly fuzzes common utilities
|
||||
# Copyright (c) 2006-2010 Sam Hocevar <sam@hocevar.net>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
#
|
||||
# This program is free software. It comes without any warranty, to
|
||||
# the extent permitted by applicable law. You can redistribute it
|
||||
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
# and/or modify it under the terms of the Do What the Fuck You Want
|
||||
# to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
# See http://www.wtfpl.net/ for more details.
|
||||
#
|
||||
|
||||
. "$(dirname "$0")/functions.inc"
|
||||
|
||||
@ -1,4 +1,15 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# check-win32 - ensure msvc/config.h is in sync with the autotools version
|
||||
#
|
||||
# Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
#
|
||||
# This program is free software. It comes without any warranty, to
|
||||
# the extent permitted by applicable law. You can redistribute it
|
||||
# and/or modify it under the terms of the Do What the Fuck You Want
|
||||
# to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
# See http://www.wtfpl.net/ for more details.
|
||||
#
|
||||
|
||||
ret=0
|
||||
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# check-zzuf-A-autoinc - test "zzuf -A" flag (auto-increment)
|
||||
# Copyright (c) 2008-2010 Sam Hocevar <sam@hocevar.net>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
#
|
||||
# This program is free software. It comes without any warranty, to
|
||||
# the extent permitted by applicable law. You can redistribute it
|
||||
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
# and/or modify it under the terms of the Do What the Fuck You Want
|
||||
# to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
# See http://www.wtfpl.net/ for more details.
|
||||
#
|
||||
|
||||
. "$(dirname "$0")/functions.inc"
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# check-zzuf-M-max-memory - check that zzuf catches excessive memory allocs
|
||||
# Copyright (c) 2008-2010 Sam Hocevar <sam@hocevar.net>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
#
|
||||
# This program is free software. It comes without any warranty, to
|
||||
# the extent permitted by applicable law. You can redistribute it
|
||||
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
# and/or modify it under the terms of the Do What the Fuck You Want
|
||||
# to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
# See http://www.wtfpl.net/ for more details.
|
||||
#
|
||||
|
||||
. "$(dirname "$0")/functions.inc"
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# check-zzuf-f-fuzzing - test "zzuf -f" flag (fuzzing mode)
|
||||
# Copyright (c) 2008-2010 Sam Hocevar <sam@hocevar.net>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
#
|
||||
# This program is free software. It comes without any warranty, to
|
||||
# the extent permitted by applicable law. You can redistribute it
|
||||
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
# and/or modify it under the terms of the Do What the Fuck You Want
|
||||
# to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
# See http://www.wtfpl.net/ for more details.
|
||||
#
|
||||
|
||||
. "$(dirname "$0")/functions.inc"
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# check-zzuf-m-md5 - test "zzuf -m" flag (md5 checksums)
|
||||
# Copyright (c) 2008-2010 Sam Hocevar <sam@hocevar.net>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
#
|
||||
# This program is free software. It comes without any warranty, to
|
||||
# the extent permitted by applicable law. You can redistribute it
|
||||
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
# and/or modify it under the terms of the Do What the Fuck You Want
|
||||
# to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
# See http://www.wtfpl.net/ for more details.
|
||||
#
|
||||
|
||||
. "$(dirname "$0")/functions.inc"
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# check-zzuf-r-ratio - zzuf RNG statistic tests
|
||||
# Copyright (c) 2008-2010 Sam Hocevar <sam@hocevar.net>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
#
|
||||
# This program is free software. It comes without any warranty, to
|
||||
# the extent permitted by applicable law. You can redistribute it
|
||||
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
# and/or modify it under the terms of the Do What the Fuck You Want
|
||||
# to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
# See http://www.wtfpl.net/ for more details.
|
||||
#
|
||||
|
||||
. "$(dirname "$0")/functions.inc"
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# check-zzuf-s-seed - zzuf seed efficiency statistic tests
|
||||
# Copyright (c) 2008-2010 Sam Hocevar <sam@hocevar.net>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
#
|
||||
# This program is free software. It comes without any warranty, to
|
||||
# the extent permitted by applicable law. You can redistribute it
|
||||
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
# and/or modify it under the terms of the Do What the Fuck You Want
|
||||
# to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
# See http://www.wtfpl.net/ for more details.
|
||||
#
|
||||
|
||||
. "$(dirname "$0")/functions.inc"
|
||||
|
||||
@ -2,14 +2,14 @@
|
||||
# . "$(dirname "$0")/functions.inc"
|
||||
#
|
||||
# functions.inc - utility functions for shell-based test scripts
|
||||
# Copyright (c) 2006-2010 Sam Hocevar <sam@hocevar.net>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# This program is free software. It comes without any warranty, to
|
||||
# Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
#
|
||||
# This library is free software. It comes without any warranty, to
|
||||
# the extent permitted by applicable law. You can redistribute it
|
||||
# and/or modify it under the terms of the Do What The Fuck You Want
|
||||
# To Public License, Version 2, as published by Sam Hocevar. See
|
||||
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
# and/or modify it under the terms of the Do What the Fuck You Want
|
||||
# to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
# See http://www.wtfpl.net/ for more details.
|
||||
#
|
||||
|
||||
DIR="$(dirname "$0")"
|
||||
|
||||
28
test/zzero.c
28
test/zzero.c
@ -1,33 +1,39 @@
|
||||
/*
|
||||
* zzero - check how many bits zzuf changes in a stream of zeroes
|
||||
* Copyright (c) 2008 Sam Hocevar <sam@hocevar.net>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
*
|
||||
* This program is free software. It comes without any warranty, to
|
||||
* the extent permitted by applicable law. You can redistribute it
|
||||
* and/or modify it under the terms of the Do What The Fuck You Want
|
||||
* To Public License, Version 2, as published by Sam Hocevar. See
|
||||
* http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
* and/or modify it under the terms of the Do What the Fuck You Want
|
||||
* to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
* See http://www.wtfpl.net/ for more details.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main(void)
|
||||
static inline int countones(uint8_t x)
|
||||
{
|
||||
static const int lut[16] =
|
||||
static int const lut[16] =
|
||||
{
|
||||
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4
|
||||
};
|
||||
|
||||
int ones = 0, ch;
|
||||
return lut[x & 0xf] + lut[x >> 4];
|
||||
}
|
||||
|
||||
while((ch = getc(stdin)) != EOF)
|
||||
ones += lut[ch & 0xf] + lut[(ch >> 4) & 0xf];
|
||||
int main(void)
|
||||
{
|
||||
int total = 0, ch;
|
||||
|
||||
printf("%i\n", ones);
|
||||
while ((ch = getc(stdin)) != EOF)
|
||||
total += countones((uint8_t)ch);
|
||||
|
||||
printf("%i\n", total);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
15
test/zznop.c
15
test/zznop.c
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* zznop - almost empty program that does almost nothing
|
||||
* Copyright (c) 2009-2010 Sam Hocevar <sam@hocevar.net>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
*
|
||||
* This program is free software. It comes without any warranty, to
|
||||
* the extent permitted by applicable law. You can redistribute it
|
||||
* and/or modify it under the terms of the Do What The Fuck You Want
|
||||
* To Public License, Version 2, as published by Sam Hocevar. See
|
||||
* http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
* and/or modify it under the terms of the Do What the Fuck You Want
|
||||
* to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
* See http://www.wtfpl.net/ for more details.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@ -15,13 +15,14 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined HAVE_WINDOWS_H
|
||||
#if HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
#if defined HAVE_WINDOWS_H
|
||||
#if HAVE_WINDOWS_H
|
||||
/* Only for debugging purposes */
|
||||
AllocConsole();
|
||||
|
||||
fprintf(stderr, "About to call LoadLibraryA()\n");
|
||||
|
||||
60
test/zzone.c
60
test/zzone.c
@ -1,48 +1,50 @@
|
||||
/*
|
||||
* zzone - check that all bits are set to one after some time
|
||||
* Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net>
|
||||
*
|
||||
* This program is free software. It comes without any warranty, to
|
||||
* the extent permitted by applicable law. You can redistribute it
|
||||
* and/or modify it under the terms of the Do What The Fuck You Want
|
||||
* To Public License, Version 2, as published by Sam Hocevar. See
|
||||
* http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
* and/or modify it under the terms of the Do What the Fuck You Want
|
||||
* to Public License, Version 2, as published by the WTFPL Task Force.
|
||||
* See http://www.wtfpl.net/ for more details.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#if defined HAVE_STDINT_H
|
||||
#if HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#elif defined HAVE_INTTYPES_H
|
||||
#elif HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
int zero[16] =
|
||||
static int countzeroes(uint8_t x)
|
||||
{
|
||||
4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0
|
||||
};
|
||||
static int const lut[16] =
|
||||
{
|
||||
4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0
|
||||
};
|
||||
|
||||
return lut[x & 0x4] + lut[x >> 4];
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
uint8_t *buf, *tmp;
|
||||
size_t i, last, size, count;
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
fprintf(stderr, "usage: zzone <size> <count>\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
size = atoi(argv[1]);
|
||||
count = atoi(argv[2]);
|
||||
last = 0;
|
||||
size_t size = atoi(argv[1]);
|
||||
size_t count = atoi(argv[2]);
|
||||
size_t last = 0;
|
||||
|
||||
buf = malloc(size);
|
||||
tmp = malloc(size);
|
||||
uint8_t *buf = malloc(size);
|
||||
uint8_t *tmp = malloc(size);
|
||||
if (!buf || !tmp)
|
||||
{
|
||||
fprintf(stderr, "zzone: cannot alloc memory\n");
|
||||
@ -53,10 +55,8 @@ int main(int argc, char *argv[])
|
||||
while (count--)
|
||||
{
|
||||
fread(tmp, size, 1, stdin);
|
||||
for (i = last; i < size; i++)
|
||||
{
|
||||
for (size_t i = last; i < size; i++)
|
||||
buf[i] |= tmp[i];
|
||||
}
|
||||
|
||||
while (last < size && buf[last] == 0xff)
|
||||
last++;
|
||||
@ -65,20 +65,10 @@ int main(int argc, char *argv[])
|
||||
free(buf);
|
||||
free(tmp);
|
||||
|
||||
if (last != size)
|
||||
{
|
||||
size_t zeros = 0;
|
||||
for (i = last; i < size; i++)
|
||||
{
|
||||
zeros += zero[buf[i] & 0xf];
|
||||
zeros += zero[buf[i] >> 4];
|
||||
}
|
||||
printf("%li\n", (long)zeros);
|
||||
}
|
||||
else
|
||||
{
|
||||
puts("0");
|
||||
}
|
||||
size_t total = 0;
|
||||
for (size_t i = last; i < size; i++)
|
||||
total += countzeroes(buf[i]);
|
||||
printf("%li\n", (long)total);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user