Skip to content

Commit f63a9df

Browse files
Marc BuergJoelgranados
authored andcommitted
sysctl: fix uninitialized variable in proc_do_large_bitmap
proc_do_large_bitmap() does not initialize variable c, which is expected to be set to a trailing character by proc_get_long(). However, proc_get_long() only sets c when the input buffer contains a trailing character after the parsed value. If c is not initialized it may happen to contain a '-'. If this is the case proc_do_large_bitmap() expects to be able to parse a second part of the input buffer. If there is no second part an unjustified -EINVAL will be returned. Initialize c to 0 to prevent returning -EINVAL on valid input. Fixes: 9f977fb ("sysctl: add proc_do_large_bitmap") Signed-off-by: Marc Buerg <[email protected]> Reviewed-by: Joel Granados <[email protected]> Signed-off-by: Joel Granados <[email protected]>
1 parent c369299 commit f63a9df

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/sysctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ int proc_do_large_bitmap(const struct ctl_table *table, int dir,
11181118
unsigned long bitmap_len = table->maxlen;
11191119
unsigned long *bitmap = *(unsigned long **) table->data;
11201120
unsigned long *tmp_bitmap = NULL;
1121-
char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1121+
char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c = 0;
11221122

11231123
if (!bitmap || !bitmap_len || !left || (*ppos && SYSCTL_KERN_TO_USER(dir))) {
11241124
*lenp = 0;

0 commit comments

Comments
 (0)