Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

befs: Validate length of long symbolic links.

Signed-off-by: Timo Warns <warns@pre-sense.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Timo Warns and committed by
Linus Torvalds
338d0f0a b4fd4ae6

+14 -9
+14 -9
fs/befs/linuxvfs.c
··· 474 474 befs_data_stream *data = &befs_ino->i_data.ds; 475 475 befs_off_t len = data->size; 476 476 477 - befs_debug(sb, "Follow long symlink"); 478 - 479 - link = kmalloc(len, GFP_NOFS); 480 - if (!link) { 481 - link = ERR_PTR(-ENOMEM); 482 - } else if (befs_read_lsymlink(sb, data, link, len) != len) { 483 - kfree(link); 484 - befs_error(sb, "Failed to read entire long symlink"); 477 + if (len == 0) { 478 + befs_error(sb, "Long symlink with illegal length"); 485 479 link = ERR_PTR(-EIO); 486 480 } else { 487 - link[len - 1] = '\0'; 481 + befs_debug(sb, "Follow long symlink"); 482 + 483 + link = kmalloc(len, GFP_NOFS); 484 + if (!link) { 485 + link = ERR_PTR(-ENOMEM); 486 + } else if (befs_read_lsymlink(sb, data, link, len) != len) { 487 + kfree(link); 488 + befs_error(sb, "Failed to read entire long symlink"); 489 + link = ERR_PTR(-EIO); 490 + } else { 491 + link[len - 1] = '\0'; 492 + } 488 493 } 489 494 } else { 490 495 link = befs_ino->i_data.symlink;