mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-05 19:00:32 -05:00
security: zero out buffers from pool before reusing them
This commit is contained in:
parent
925a503604
commit
18780db853
3 changed files with 9 additions and 1 deletions
|
|
@ -16,6 +16,10 @@ let clear self : unit =
|
|||
self.bytes <- self.original;
|
||||
self.i <- 0
|
||||
|
||||
let clear_and_zero self =
|
||||
clear self;
|
||||
Bytes.fill self.bytes 0 (Bytes.length self.bytes) '\x00'
|
||||
|
||||
let resize self new_size : unit =
|
||||
let new_buf = Bytes.make new_size ' ' in
|
||||
Bytes.blit self.bytes 0 new_buf 0 self.i;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ val clear : t -> unit
|
|||
val create : ?size:int -> unit -> t
|
||||
val contents : t -> string
|
||||
|
||||
val clear_and_zero : t -> unit
|
||||
(** Clear the buffer and zero out its storage.
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val bytes_slice : t -> bytes
|
||||
(** Access underlying slice of bytes.
|
||||
@since 0.5 *)
|
||||
|
|
|
|||
|
|
@ -847,7 +847,7 @@ let create_from ?(buf_size = 16 * 1_024) ?(middlewares = []) ~backend () : t =
|
|||
middlewares = [];
|
||||
middlewares_sorted = lazy [];
|
||||
buf_pool =
|
||||
Pool.create ~clear:Buf.clear
|
||||
Pool.create ~clear:Buf.clear_and_zero
|
||||
~mk_item:(fun () -> Buf.create ~size:buf_size ())
|
||||
();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue