Skip to contentSkip to conversation

queue-export: fix crash

PATCH Applied Alan Jenkins 2 participants 2 messages May 28, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 queue-export: fix crash

The math in skip_to() was the wrong way round and allocated a variable size array on the stack with a massively negative size.

---
 udev/lib/libudev-queue-export.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
udev/lib/libudev-queue-export.c +2 -2
index ddb1974..a36ff51 100644
@@ -115,8 +115,8 @@ static int skip_to(FILE *file, long offset)
 
 	/* fseek may drop buffered data, avoid it for small seeks */
 	old_offset = ftell(file);
-	if (offset > old_offset && old_offset - offset <= BUFSIZ) {
-		size_t skip_bytes = old_offset - offset;
+	if (offset > old_offset && offset - old_offset <= BUFSIZ) {
+		size_t skip_bytes = offset - old_offset;
 		char buf[skip_bytes];
 
 		if (fread(buf, skip_bytes, 1, file) != skip_bytes)
Signature · 1 line
1.5.4.3
Applied
#1 lore raw
Quoted 2 lines · Alan Jenkins

The math in skip_to() was the wrong way round and allocated a variable size array on the stack with a massively negative size.

Applied.

Thanks,
Kay