[batctl] Fix array out of bound exception

Message ID 20091211210623.GA3538@Linus-Debian (mailing list archive)
State Accepted, archived
Headers

Commit Message

Linus Lüssing Dec. 11, 2009, 9:06 p.m. UTC
  This patch fixes an array out of bound exception in line 201 of
functions.c. We need to reserve one extra character for the
appended null character.

Signed-off-by: Linus Lüssing <linus.luessing@web.de>
---
  

Comments

Simon Wunderlich Dec. 14, 2009, 10:24 p.m. UTC | #1
Dear Linus,

thank you for your patch, i have applied it in svn r1496.

On Fri, Dec 11, 2009 at 10:06:23PM +0100, Linus Lüssing wrote:
> This patch fixes an array out of bound exception in line 201 of
> functions.c. We need to reserve one extra character for the
> appended null character.
> 
> Signed-off-by: Linus Lüssing <linus.luessing@web.de>
> ---
> 
> Index: batctl/functions.c
> ===================================================================
> --- batctl/functions.c	(revision 1491)
> +++ batctl/functions.c	(working copy)
> @@ -161,10 +161,10 @@
>  
>  	if (read_opt & USE_READ_BUFF) {
>  		read_ptr = read_buff;
> -		read_len = sizeof(read_buff);
> +		read_len = sizeof(read_buff)-1;
>  	} else {
>  		read_ptr = lbuff;
> -		read_len = sizeof(lbuff);
> +		read_len = sizeof(lbuff)-1;
>  	}
>  
>  open:
> _______________________________________________
> B.A.T.M.A.N mailing list
> B.A.T.M.A.N@lists.open-mesh.net
> https://lists.open-mesh.net/mm/listinfo/b.a.t.m.a.n
  

Patch

Index: batctl/functions.c
===================================================================
--- batctl/functions.c	(revision 1491)
+++ batctl/functions.c	(working copy)
@@ -161,10 +161,10 @@ 
 
 	if (read_opt & USE_READ_BUFF) {
 		read_ptr = read_buff;
-		read_len = sizeof(read_buff);
+		read_len = sizeof(read_buff)-1;
 	} else {
 		read_ptr = lbuff;
-		read_len = sizeof(lbuff);
+		read_len = sizeof(lbuff)-1;
 	}
 
 open: