Skip to contentSkip to conversation

batman-adv: check proto length before accessing proto string buffer

PATCH In review Marek Lindner 2 participants 3 messages Apr 27, 2013 – Apr 29, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 batman-adv: check proto length before accessing proto string buffer

batadv_param_set_ra() strips the trailing '\n' from the supplied string buffer without checking the length of the buffer first. This patches avoids random memory access and associated potential crashes.

---
 main.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
main.c +1 -1
index 8a8fd00..f07dd6b 100644
@@ -1106,7 +1106,7 @@ static int batadv_param_set_ra(const char *val, const struct kernel_param *kp)
 	char *algo_name = (char *)val;
 	size_t name_len = strlen(algo_name);
 
-	if (algo_name[name_len - 1] == '\n')
+	if (name_len > 0 && algo_name[name_len - 1] == '\n')
 		algo_name[name_len - 1] = '\0';
 
 	bat_algo_ops = batadv_algo_get(algo_name);
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 7 lines · Marek Lindner

batadv_param_set_ra() strips the trailing '\n' from the supplied string buffer without checking the length of the buffer first. This patches avoids random memory access and associated potential crashes.

Thank you for fixing this!

Please, merge this patch in maint.

Cheers,

Signature · 4 lines
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara
author Applied
#2 lore raw
Quoted 8 lines · On Sunday, April 28, 2013 00:01:32 Antonio Quartulli wrote:
Quoted 7 lines · Marek Lindner

batadv_param_set_ra() strips the trailing '\n' from the supplied string buffer without checking the length of the buffer first. This patches avoids random memory access and associated potential crashes.

Quoted 6 lines
Quoted 2 lines

Thank you for fixing this!

Please, merge this patch in maint.

Applied in revision aa7d19a.

Regards,
Marek