Skip to content

Commit 46920fb

Browse files
committed
Do not try to read more bytes from input than provided Content-Length value.
1 parent d50b3cb commit 46920fb

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

library/server/wsf/src/wsf_request.e

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -294,24 +294,27 @@ feature -- Access: Input
294294
until
295295
l_step = 0 or l_input.end_of_input
296296
loop
297-
l_input.append_to_string (s, l_step)
298-
nb := l_input.last_appended_count
299-
l_size := l_size + nb.to_natural_64
300-
len := len - nb.to_natural_64
301-
302-
debug ("wsf")
303-
io.error.put_string (" append (s, " + l_step.out + ") -> " + nb.out + " (" + l_size.out + " / "+ content_length_value.out + ")%N")
297+
if len < l_step.to_natural_64 then
298+
l_step := len.to_integer_32
304299
end
300+
if l_step > 0 then
301+
l_input.append_to_string (s, l_step)
302+
nb := l_input.last_appended_count
303+
l_size := l_size + nb.to_natural_64
304+
len := len - nb.to_natural_64
305+
306+
debug ("wsf")
307+
io.error.put_string (" append (s, " + l_step.out + ") -> " + nb.out + " (" + l_size.out + " / "+ content_length_value.out + ")%N")
308+
end
305309

306-
a_file.put_string (s)
307-
if l_raw_data /= Void then
308-
l_raw_data.append (s)
309-
end
310-
s.wipe_out
311-
if nb < l_step then
312-
l_step := 0
313-
elseif len < l_step.to_natural_64 then
314-
l_step := len.to_integer_32
310+
a_file.put_string (s)
311+
if l_raw_data /= Void then
312+
l_raw_data.append (s)
313+
end
314+
s.wipe_out
315+
if nb < l_step then
316+
l_step := 0
317+
end
315318
end
316319
end
317320
a_file.flush
@@ -2065,7 +2068,7 @@ invariant
20652068
wgi_request.content_type /= Void implies content_type /= Void
20662069

20672070
note
2068-
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
2071+
copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
20692072
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
20702073
source: "[
20712074
Eiffel Software

0 commit comments

Comments
 (0)