[1/2] aviocat: Check the argv array length before reading element i+1

Message ID 1389876189-47570-1-git-send-email-martin@martin.st
State Committed
Commit 03f2de5856ec8571fcf5f4cf6dccc713294af545
Headers show

Commit Message

Martin Storsjö Jan. 16, 2014, 12:43 p.m.
---
 tools/aviocat.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Luca Barbato Jan. 16, 2014, 12:59 p.m. | #1
On 16/01/14 13:43, Martin Storsjö wrote:
> ---
>  tools/aviocat.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/aviocat.c b/tools/aviocat.c
> index 52a96bd..9284db1 100644
> --- a/tools/aviocat.c
> +++ b/tools/aviocat.c
> @@ -43,7 +43,7 @@ int main(int argc, char **argv)
>      avformat_network_init();
>  
>      for (i = 1; i < argc; i++) {
> -        if (!strcmp(argv[i], "-b")) {
> +        if (!strcmp(argv[i], "-b") && i + 1 < argc) {
>              bps = atoi(argv[i + 1]);
>              i++;
>          } else if (!input_url) {
> 

Ok.

Patch

diff --git a/tools/aviocat.c b/tools/aviocat.c
index 52a96bd..9284db1 100644
--- a/tools/aviocat.c
+++ b/tools/aviocat.c
@@ -43,7 +43,7 @@  int main(int argc, char **argv)
     avformat_network_init();
 
     for (i = 1; i < argc; i++) {
-        if (!strcmp(argv[i], "-b")) {
+        if (!strcmp(argv[i], "-b") && i + 1 < argc) {
             bps = atoi(argv[i + 1]);
             i++;
         } else if (!input_url) {