Gleb Chesnokov
87235dfe3a
scst: Use vmalloc_array() and vcalloc()
Use vmalloc_array() and vcalloc() to protect against multiplication
overflows.
The changes were done using the following Coccinelle
semantic patch:
// <smpl>
@initialize:ocaml@
@@
let rename alloc =
match alloc with
"vmalloc" -> "vmalloc_array"
| "vzalloc" -> "vcalloc"
| _ -> failwith "unknown"
@@
size_t e1,e2;
constant C1, C2;
expression E1, E2, COUNT, x1, x2, x3;
typedef u8;
typedef __u8;
type t = {u8,__u8,char,unsigned char};
identifier alloc = {vmalloc,vzalloc};
fresh identifier realloc = script:ocaml(alloc) { rename alloc };
@@
(
alloc(x1*x2*x3)
|
alloc(C1 * C2)
|
alloc((sizeof(t)) * (COUNT), ...)
|
- alloc((e1) * (e2))
+ realloc(e1, e2)
|
- alloc((e1) * (COUNT))
+ realloc(COUNT, e1)
|
- alloc((E1) * (E2))
+ realloc(E1, E2)
)
// </smpl>
2023-07-21 10:38:34 +03:00
..
2020-05-17 21:06:37 +00:00
2023-06-14 16:49:36 +03:00
2019-03-29 01:29:46 +00:00
2020-05-09 22:54:47 +00:00
2020-05-09 22:54:47 +00:00
2021-09-05 15:42:16 +00:00
2020-12-20 02:07:40 +00:00
2023-06-14 16:49:36 +03:00
2021-09-09 02:57:47 +00:00
2023-07-19 11:35:51 +03:00
2023-07-19 11:45:31 +03:00
2022-11-09 10:46:27 +03:00
2022-11-09 10:46:27 +03:00
2022-11-09 10:46:27 +03:00
2023-07-21 10:38:34 +03:00
2019-03-29 01:29:46 +00:00
2023-03-12 13:24:07 +03:00
2019-05-02 15:05:58 +00:00
2023-03-13 14:58:28 +03:00
2023-07-19 11:45:31 +03:00
2023-03-12 13:24:07 +03:00
2022-11-09 10:46:27 +03:00
2023-07-19 11:35:51 +03:00
2023-07-19 11:35:51 +03:00
2023-07-21 10:38:34 +03:00
2023-07-19 11:45:31 +03:00
2023-07-21 10:38:34 +03:00
2023-07-19 11:35:51 +03:00
2023-03-12 13:24:07 +03:00
2023-04-28 15:22:58 +03:00
2023-07-19 10:54:35 +03:00
2021-05-15 20:31:02 +00:00
2023-07-19 11:45:31 +03:00
2022-04-04 20:29:04 +03:00
2022-04-04 20:14:51 +03:00
2020-12-28 19:14:28 +00:00
2022-04-04 20:14:51 +03:00
2022-04-04 20:14:51 +03:00
2023-07-19 11:35:51 +03:00
2020-12-28 19:14:28 +00:00
2022-04-04 19:56:13 +03:00
2023-04-28 15:22:58 +03:00
2023-03-12 13:24:07 +03:00
2022-04-04 19:56:13 +03:00
2020-12-28 23:46:16 +00:00
2023-07-19 11:45:31 +03:00