All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libblkid exfat.c: Limit maximum number of iterations in find_label
@ 2016-08-30 10:07 Rostislav Skudnov
  2016-08-30 10:45 ` Karel Zak
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rostislav Skudnov @ 2016-08-30 10:07 UTC (permalink / raw)
  To: util-linux

Do not hang if there is a cluster chain loop in rootdir
---
 libblkid/src/superblocks/exfat.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libblkid/src/superblocks/exfat.c b/libblkid/src/superblocks/exfat.c
index 01ed30b..e058423 100644
--- a/libblkid/src/superblocks/exfat.c
+++ b/libblkid/src/superblocks/exfat.c
@@ -86,8 +86,10 @@ static struct exfat_entry_label *find_label(blkid_probe pr,
 	uint32_t cluster = le32_to_cpu(sb->rootdir_cluster);
 	uint64_t offset = cluster_to_offset(sb, cluster);
 	uint8_t *entry;
+	const size_t max_iter = 10000;
+	size_t i = 0;
 
-	for (;;) {
+	for (; i<max_iter; i++) {
 		entry = (uint8_t *) blkid_probe_get_buffer(pr, offset,
 				EXFAT_ENTRY_SIZE);
 		if (!entry)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] libblkid exfat.c: Limit maximum number of iterations in find_label
  2016-08-30 10:07 [PATCH] libblkid exfat.c: Limit maximum number of iterations in find_label Rostislav Skudnov
@ 2016-08-30 10:45 ` Karel Zak
       [not found] ` <5af8ca2ea7cc4a77b41171b457d32229@nebula-exfe-01.nebula.local>
  2016-08-30 11:52 ` Karel Zak
  2 siblings, 0 replies; 4+ messages in thread
From: Karel Zak @ 2016-08-30 10:45 UTC (permalink / raw)
  To: Rostislav Skudnov; +Cc: util-linux

On Tue, Aug 30, 2016 at 10:07:49AM +0000, Rostislav Skudnov wrote:
> Do not hang if there is a cluster chain loop in rootdir
> ---
>  libblkid/src/superblocks/exfat.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libblkid/src/superblocks/exfat.c b/libblkid/src/superblocks/exfat.c
> index 01ed30b..e058423 100644
> --- a/libblkid/src/superblocks/exfat.c
> +++ b/libblkid/src/superblocks/exfat.c
> @@ -86,8 +86,10 @@ static struct exfat_entry_label *find_label(blkid_probe pr,
>  	uint32_t cluster = le32_to_cpu(sb->rootdir_cluster);
>  	uint64_t offset = cluster_to_offset(sb, cluster);
>  	uint8_t *entry;
> +	const size_t max_iter = 10000;

for FAT we have 100 as the limit, would be this smaller number
better?

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libblkid exfat.c: Limit maximum number of iterations in find_label
       [not found] ` <5af8ca2ea7cc4a77b41171b457d32229@nebula-exfe-01.nebula.local>
@ 2016-08-30 10:54   ` Rostislav
  0 siblings, 0 replies; 4+ messages in thread
From: Rostislav @ 2016-08-30 10:54 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux


> On Aug 30, 2016, at 1:45 PM, Karel Zak <kzak@redhat.com> wrote:
> 
> On Tue, Aug 30, 2016 at 10:07:49AM +0000, Rostislav Skudnov wrote:
>> Do not hang if there is a cluster chain loop in rootdir
>> ---
>> libblkid/src/superblocks/exfat.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>> 
>> diff --git a/libblkid/src/superblocks/exfat.c b/libblkid/src/superblocks/exfat.c
>> index 01ed30b..e058423 100644
>> --- a/libblkid/src/superblocks/exfat.c
>> +++ b/libblkid/src/superblocks/exfat.c
>> @@ -86,8 +86,10 @@ static struct exfat_entry_label *find_label(blkid_probe pr,
>> 	uint32_t cluster = le32_to_cpu(sb->rootdir_cluster);
>> 	uint64_t offset = cluster_to_offset(sb, cluster);
>> 	uint8_t *entry;
>> +	const size_t max_iter = 10000;
> 
> for FAT we have 100 as the limit, would be this smaller number
> better?
> 
>    Karel
> 
> -- 
> Karel Zak  <kzak@redhat.com>
> http://karelzak.blogspot.com
As far as I understand, in vfat we walk over 100 clusters, each of which may have many direntries. Here 10000 is the max number of direntries we visit.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libblkid exfat.c: Limit maximum number of iterations in find_label
  2016-08-30 10:07 [PATCH] libblkid exfat.c: Limit maximum number of iterations in find_label Rostislav Skudnov
  2016-08-30 10:45 ` Karel Zak
       [not found] ` <5af8ca2ea7cc4a77b41171b457d32229@nebula-exfe-01.nebula.local>
@ 2016-08-30 11:52 ` Karel Zak
  2 siblings, 0 replies; 4+ messages in thread
From: Karel Zak @ 2016-08-30 11:52 UTC (permalink / raw)
  To: Rostislav Skudnov; +Cc: util-linux

On Tue, Aug 30, 2016 at 10:07:49AM +0000, Rostislav Skudnov wrote:
>  libblkid/src/superblocks/exfat.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-30 11:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-30 10:07 [PATCH] libblkid exfat.c: Limit maximum number of iterations in find_label Rostislav Skudnov
2016-08-30 10:45 ` Karel Zak
     [not found] ` <5af8ca2ea7cc4a77b41171b457d32229@nebula-exfe-01.nebula.local>
2016-08-30 10:54   ` Rostislav
2016-08-30 11:52 ` Karel Zak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.