News for hackers. Stuff that matters.
Re:Windows has a new wormable vulnerability, with no patch by IshKebab on Wednesday March 11, 2020 @05:46PM (#22551116)
This is really misleading and I wish people would stop but for some reason everyone is like "Rust is actually easy! You already have to think about borrowing and lifetimes in C/C++ - Rust just makes it explicit.".

I love Rust, but that is nonsense. First of all it's a reasonable complicated language even without lifetimes and the borrow checker, but let's ignore that. My issue with this sentiment is that it ignores the fact that the borrow checker isn't smart enough to prove that loads of perfectly valid programs are valid.

A simple example: `a[0].foo = a[1].foo;`. Perfectly valid. No memory errors. But Rust isn't smart enough to know, and so it really does make things harder than in C/C++.

This isn't a criticism of Rust at all. I think it is a worthwhile tradeoff to get memory safety. I just wish people would stop pretending that it isn't a tradeoff at all!

Re:Windows has a new wormable vulnerability, with no patch by lonelappde on Friday March 13, 2020 @09:18AM (#22567009)
How do you copy data from one array of structs to another in rust?

Also, if foo is a non-shared pointer that copy doesn't seem safe.

Re:Windows has a new wormable vulnerability, with no patch by steveklabnik on Friday March 13, 2020 @10:26AM (#22567475)
> How do you copy data from one array of structs to another in rust?

Depends on exactly what you mean; if you're trying to say, replace one part of an array with another, you would use copy_from_slice https://play.rust-lang.org/?version=stable&mode=debug&editio... (or clone_from_slice if your struct isn't Copy)

Also, your parent is just plain incorrect, Rust does let you do that https://play.rust-lang.org/?version=stable&mode=debug&editio...

Re:Windows has a new wormable vulnerability, with no patch by IshKebab on Sunday March 15, 2020 @05:25PM (#22586898)
Sorry, you are correct. I was thinking of situations like this:

  fn assign(a: &mut Bar, b: &Bar) {
    a.foo = b.foo;
  }
    
    assign(&mut a[0], &a[1]);
Bit contrived - next time Rust stops me doing something simple I will note it down!

Again to be clear, I'm not saying that there's anything wrong with Rust here.

Re:Windows has a new wormable vulnerability, with no patch by steveklabnik on Monday March 16, 2020 @09:30AM (#22592469)
Ah yeah, you can split_at_mut here, but you're right that that's an actual error. My bad!