Skip to content

Remove casts to size_t in Rust code #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
briansmith opened this issue Aug 30, 2015 · 2 comments
Closed

Remove casts to size_t in Rust code #4

briansmith opened this issue Aug 30, 2015 · 2 comments

Comments

@briansmith
Copy link
Owner

See rust-lang/rust/#28096.

There are some casts like digest.len() as libc::size_t that are potentially truncating and thus unsafe. At the same time, the comments in the code questioning the safety of such casts need to be removed.

This will have to wait for a higher-versioned released of the libc crate with rust-lang/rust#28096 merged into it.

@briansmith
Copy link
Owner Author

This depends on rust-lang/rust#28779. That was merged to the Rust beta branch in rust-lang/rust#29112 so we can probably do this soon.

@briansmith
Copy link
Owner Author

Fixed in 377f611 by dropping the dependency on the libc crate and defining our own size_t type: ring::c::size_t.

tomaka pushed a commit to tomaka/ring that referenced this issue Jul 4, 2018
backwardn pushed a commit to backwardn/ring that referenced this issue Nov 20, 2019
Fix generateMultiHash write data to source data slice
briansmith added a commit that referenced this issue Apr 8, 2025
This changes the codegen for places where we call `cpu::features()` as expected.

Examples:

```
 	adrp	x8, :got:_ZN4ring3cpu3arm12featureflags8FEATURES17habb4a2487137fb15E
 	mov	x19, x0
	ldr	x8, [x8, :got_lo12:_ZN4ring3cpu3arm12featureflags8FEATURES17habb4a2487137fb15E]
-	ldar	x8, [x8]
+	ldr	x8, [x8]
 	cbz	x8, .LBB86_2
```

```
 	adrp	x8, :got:_ZN4ring3cpu3arm12featureflags8FEATURES17habb4a2487137fb15E
 	mov	x19, x4
 	mov	x20, x3
 	ldr	x8, [x8, :got_lo12:_ZN4ring3cpu3arm12featureflags8FEATURES17habb4a2487137fb15E]
 	mov	x21, x2
 	mov	x22, x0
 	sub	x23, x3, #4
-	ldar	x8, [x8]
+	ldr	x8, [x8]
 	cbz	x8, .LBB84_8
```
briansmith added a commit that referenced this issue Apr 10, 2025
This changes the codegen for places where we call `cpu::features()` as expected.

Examples:

```
 	adrp	x8, :got:_ZN4ring3cpu3arm12featureflags8FEATURES17habb4a2487137fb15E
 	mov	x19, x0
	ldr	x8, [x8, :got_lo12:_ZN4ring3cpu3arm12featureflags8FEATURES17habb4a2487137fb15E]
-	ldar	x8, [x8]
+	ldr	x8, [x8]
 	cbz	x8, .LBB86_2
```

```
 	adrp	x8, :got:_ZN4ring3cpu3arm12featureflags8FEATURES17habb4a2487137fb15E
 	mov	x19, x4
 	mov	x20, x3
 	ldr	x8, [x8, :got_lo12:_ZN4ring3cpu3arm12featureflags8FEATURES17habb4a2487137fb15E]
 	mov	x21, x2
 	mov	x22, x0
 	sub	x23, x3, #4
-	ldar	x8, [x8]
+	ldr	x8, [x8]
 	cbz	x8, .LBB84_8
```
briansmith added a commit that referenced this issue Apr 10, 2025
This changes the codegen for places where we call `cpu::features()` as expected.

Examples:

```
 	adrp	x8, :got:_ZN4ring3cpu3arm12featureflags8FEATURES17habb4a2487137fb15E
 	mov	x19, x0
	ldr	x8, [x8, :got_lo12:_ZN4ring3cpu3arm12featureflags8FEATURES17habb4a2487137fb15E]
-	ldar	x8, [x8]
+	ldr	x8, [x8]
 	cbz	x8, .LBB86_2
```

```
 	adrp	x8, :got:_ZN4ring3cpu3arm12featureflags8FEATURES17habb4a2487137fb15E
 	mov	x19, x4
 	mov	x20, x3
 	ldr	x8, [x8, :got_lo12:_ZN4ring3cpu3arm12featureflags8FEATURES17habb4a2487137fb15E]
 	mov	x21, x2
 	mov	x22, x0
 	sub	x23, x3, #4
-	ldar	x8, [x8]
+	ldr	x8, [x8]
 	cbz	x8, .LBB84_8
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant