Skip to content

Commit

Permalink
Block: Fix block/elevator.c elevator_get() off-by-one error
Browse files Browse the repository at this point in the history
elevator_get() not check the name length, if the name length > sizeof(elv),
elv will miss the '\0'. And elv buffer will be replace "-iosched" as something
like aaaaaaaaa, then call request_module() can load an not trust module.

Signed-off-by: Zhitong Wang <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
cloudsec authored and Jens Axboe committed Apr 2, 2010
1 parent b2b163d commit a506aed
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion block/elevator.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static struct elevator_type *elevator_get(const char *name)

spin_unlock(&elv_list_lock);

sprintf(elv, "%s-iosched", name);
snprintf(elv, sizeof(elv), "%s-iosched", name);

request_module("%s", elv);
spin_lock(&elv_list_lock);
Expand Down

0 comments on commit a506aed

Please sign in to comment.