Skip to content

Commit 05bd4cc

Browse files
committed
Typos
1 parent 30a48f1 commit 05bd4cc

File tree

2 files changed

+78
-78
lines changed

2 files changed

+78
-78
lines changed

src/en/07_ffi.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ the C standard library.
229229
230230
### Non-robust types: references, function pointers, enums
231231
232-
A *trap representation* of a particular type is a representation (pattern of
232+
A _trap representation_ of a particular type is a representation (pattern of
233233
bits) that respects the type's representation constraints (such as size and
234234
alignment) but does not represent a valid value of this type and leads to
235235
undefined behavior.
@@ -253,15 +253,15 @@ the C-compatible types:
253253
- compound types that contain a field of a non-robust type.
254254
255255
On the other hand, integer types (`u*`/`i*`), packed compound types that contain
256-
no non-robust fields, for instance are *robust types*.
256+
no non-robust fields, for instance are _robust types_.
257257
258258
Non-robust types are a difficulty when interfacing two languages. It revolves
259259
into deciding **which language of the two is responsible in asserting the
260260
validity of boundary-crossing values** and how to do it.
261261
262262
> ### Rule {{#check FFI-CKNONROBUST | Do not use unchecked non-robust foreign values}}
263263
>
264-
> In a secure Rust development, there must not be any use of *unchecked* foreign
264+
> In a secure Rust development, there must not be any use of _unchecked_ foreign
265265
> values of non-robust types.
266266
>
267267
> In other words, either Rust translates robust types to non-robust types
@@ -288,10 +288,10 @@ function references, and enums, and are discussed below.
288288
>
289289
> Rust's `bool` has been made equivalent to C99's `_Bool` (aliased as `bool`
290290
> in `<stdbool.h>`) and C++'s `bool`. However, loading a value other than 0 and
291-
> 1 as a `_Bool`/`bool` is an undefined behavior *on both sides*.
291+
> 1 as a `_Bool`/`bool` is an undefined behavior _on both sides_.
292292
> Safe Rust ensures that. Standard-compliant C and C++ compilers ensure that no
293-
> value but 0 and 1 can be *stored* in a `_Bool`/`bool` value but cannot
294-
> guarantee the absence of an *incorrect reinterpretation* (e.g., union types,
293+
> value but 0 and 1 can be _stored_ in a `_Bool`/`bool` value but cannot
294+
> guarantee the absence of an _incorrect reinterpretation_ (e.g., union types,
295295
> pointer cast). To detect such a bad reinterpretation, sanitizers such as
296296
> LLVM's `-fsanitize=bool` may be used.
297297
@@ -317,7 +317,7 @@ Rust references may be used reasonably with other C-compatible languages
317317
including C variants allowing for non-null type checking, e.g. Microsoft SAL
318318
annotated code.
319319
320-
On the other hand, Rust's *pointer types* may also lead to undefined behaviors
320+
On the other hand, Rust's _pointer types_ may also lead to undefined behaviors
321321
but are more verifiable, mostly against `std/core::ptr::null()` (C's `(void*)0`)
322322
but also in some context against a known valid memory range (particularly in
323323
embedded systems or kernel-level programming). Another advantage of using Rust
@@ -345,7 +345,7 @@ an `unsafe` block or function.
345345
> In a secure Rust development, every foreign references that is transmitted to
346346
> Rust through FFI must be **checked on the foreign side** either automatically
347347
> (for instance, by a compiler) or manually.
348-
>
348+
>
349349
> Exceptions include Rust references in an opaque wrapping that is created
350350
> and manipulated only from the Rust side and `Option`-wrapped references
351351
> (see Note below).
@@ -358,7 +358,7 @@ an `unsafe` block or function.
358358
> pointer must check their validity beforehand.
359359
> In particular, pointers must be checked to be non-null before any use.
360360
>
361-
> Stronger approaches are advisable when possible. They includes checking
361+
> Stronger approaches are advisable when possible. They include checking
362362
> pointers against known valid memory range or tagging (or signing) pointers
363363
> (particularly applicable if the pointed value is only manipulated from Rust).
364364
@@ -378,7 +378,7 @@ pub unsafe extern fn add_in_place(a: *mut u32, b: u32) {
378378
```
379379

380380
Note that the methods `as_ref` and `as_mut` (for mutable pointers) allows easy
381-
access to a reference while ensuring a null check in a very *Rusty* way.
381+
access to a reference while ensuring a null check in a very _Rusty_ way.
382382
On the other side in C, it can be used as follows:
383383

384384
```c
@@ -463,7 +463,7 @@ severe consequences on software security. Unfortunately, checking an `enum`
463463
value at the FFI boundary is not simple on both sides.
464464
465465
On the Rust side, it consists to actually use an integer type in the `extern`
466-
block declaration, a *robust* type, and then to perform a checked conversion
466+
block declaration, a _robust_ type, and then to perform a checked conversion
467467
to the enum type.
468468
469469
On the foreign side, it is possible only if the other language allows for
@@ -560,13 +560,13 @@ The same is true for other kind of resources such as sockets or files.
560560
Rust tracks variable ownership and lifetime to determine at compilation time if
561561
and when memory should be deallocated. Thanks to the `Drop` trait, one can
562562
exploit this system to reclaim other kind of resources such as file or network
563-
access. *Moving* some piece of data from Rust to a foreign language means also
563+
access. _Moving_ some piece of data from Rust to a foreign language means also
564564
abandoning the possible reclamations associated with it.
565565

566566
> ### Rule {{#check FFI-MEM-NODROP | Do not use types that implement `Drop` at FFI boundary}}
567567
>
568568
> In a secure Rust development, Rust code must not implement `Drop` for any
569-
> types that are directly transmitted to foreign code (i.e. not through a
569+
> types that are directly transmitted to foreign code (i.e. not through a
570570
> pointer or reference).
571571
572572
In fact, it is advisable to only use `Copy` types. Note that `*const T` is
@@ -594,10 +594,10 @@ wrapper around the foreign type:
594594

595595
> ### Recommendation {{#check FFI-MEM-WRAPPING | Wrap foreign data in memory releasing wrapper}}
596596
>
597-
> In a secure Rust development, any non-sensitive foreign piece of data that are
597+
> In a secure Rust development, any non-sensitive foreign piece of data that is
598598
> allocated and deallocated in the foreign language should be encapsulated in a
599599
> `Drop` type in such a way as to provide automatic deallocation in Rust,
600-
> through an automatic call to the foreing language deallocation routine.
600+
> through an automatic call to the foreign language deallocation routine.
601601
602602
A simple example of Rust wrapping over an external opaque type:
603603

@@ -653,7 +653,7 @@ impl Drop for Foo {
653653

654654
> ### Warning
655655
>
656-
> Because panics may lead to not running the `Drop::drop` method this solution
656+
> Because panics may lead to not running the `Drop::drop` method, this solution
657657
> is not sufficient for sensitive deallocation (such as wiping sensitive data)
658658
> except if the code is guaranteed to never panic.
659659
>
@@ -834,7 +834,7 @@ trick: the linker fails if a non-trivially-dead branch leads to `panic!`.
834834
> Interfacing a library written in another language in Rust should be done in
835835
> two parts:
836836
>
837-
> - a low-level, possibly *hidden*, module that closely translates the original
837+
> - a low-level, possibly _hidden_, module that closely translates the original
838838
> C API into `extern` blocks,
839839
> - a safe wrapping module that ensures memory safety and security invariants at
840840
> the Rust level.

0 commit comments

Comments
 (0)