Hello Justin,

On Wed,  2 Dec 2015 01:45:30 +0200
Justin Swartz <[email protected]> wrote:

> Script size argument detection: argc should be greater than one,
> rather than not equal to zero.
> 
> Output loop termination: the index variable should be compared against
> the value of the size variable, as opposed to the default SCRIPT_SIZE
> definition.
> 
> munmap: the mapping returned by mmap, addr, should be unmapped instead
> of NULL.
> 
> Signed-off-by: Justin Swartz <[email protected]>
> ---
>  script_extractor.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/script_extractor.c b/script_extractor.c
> index 52d817f..bc67b7a 100644
> --- a/script_extractor.c
> +++ b/script_extractor.c
> @@ -18,6 +18,7 @@
>  #include <fcntl.h>
>  #include <stdio.h>
>  #include <stdlib.h>
> +#include <unistd.h>
>  #include <sys/mman.h>
>  #include <sys/stat.h>
>  #include <sys/types.h>
> @@ -34,13 +35,13 @@ int main(int argc, char *argv[]) {
>       fd = open("/dev/mem", O_RDONLY);
>  
>       size = SCRIPT_SIZE;
> -     if (argc)
> +     if (argc > 1)
>               size = atoi(argv[1]);
>  
>       addr = (char *)mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 
> SCRIPT_START);
> -     for (i = 0; i < SCRIPT_SIZE; i++)
> +     for (i = 0; i < size; i++)
>               putchar(addr[i]);
> -     munmap(NULL, SCRIPT_SIZE);
> +     munmap(addr, size);
>       close(fd);
>  
>       return 0;

Thanks for the patch. But looks like Hans de Goede has also
independently encountered the same bugs and already fixed them:

https://github.com/linux-sunxi/sunxi-tools/commit/55eec70ceafc4b8b25b4ddcd613c9ca10e41dcf7

-- 
Best regards,
Siarhei Siamashka

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to