Skip to content

Commit 84c7a09

Browse files
committed
Fix Key.sign by setting buffer length
The truncate() method doesn't do anything if the "len" is greater than the current length, which is the case here. So instead, use the Vec.set_len method. Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
1 parent d8a37cf commit 84c7a09

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/api.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,9 @@ impl Key {
935935
let mut buffer = Vec::with_capacity(support.max_sig_size as usize);
936936
let write_buffer = buffer.get_backing_buffer();
937937
let sz = keyctl_pkey_sign(self.id, &info, data, write_buffer)?;
938-
buffer.truncate(sz);
938+
unsafe {
939+
buffer.set_len(sz);
940+
}
939941
Ok(buffer)
940942
}
941943

0 commit comments

Comments
 (0)