Fix same type collapse in primary index

While this would normally be treated as a security hole, since this
is a beta release, we can release this as a patch.

Closes #325
next
Sayan Nandan 9 months ago
parent 6c50a4042a
commit f6a2763b09

10
Cargo.lock generated

@ -607,7 +607,7 @@ checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
[[package]]
name = "libsky"
version = "0.8.0-beta"
version = "0.8.0-beta.2"
[[package]]
name = "linux-raw-sys"
@ -1165,7 +1165,7 @@ dependencies = [
[[package]]
name = "sky-bench"
version = "0.8.0-beta"
version = "0.8.0-beta.2"
dependencies = [
"crossbeam-channel",
"env_logger",
@ -1178,7 +1178,7 @@ dependencies = [
[[package]]
name = "sky_macros"
version = "0.8.0-beta"
version = "0.8.0-beta.2"
dependencies = [
"libsky",
"proc-macro2",
@ -1188,7 +1188,7 @@ dependencies = [
[[package]]
name = "skyd"
version = "0.8.0-beta"
version = "0.8.0-beta.2"
dependencies = [
"bytes",
"crc",
@ -1214,7 +1214,7 @@ dependencies = [
[[package]]
name = "skysh"
version = "0.8.0-beta"
version = "0.8.0-beta.2"
dependencies = [
"crossterm",
"libsky",

@ -1,6 +1,6 @@
[package]
name = "skysh"
version = "0.8.0-beta"
version = "0.8.0-beta.2"
authors = ["Sayan Nandan <ohsayan@outlook.com>"]
edition = "2021"
description = "The Skytable Shell (skysh)"

@ -1,4 +1,4 @@
skysh 0.8.0-beta
skysh 0.8.0-beta.2
Sayan N. <ohsayan@outlook.com>
The Skytable interactive shell (skysh)

@ -2,7 +2,7 @@
authors = ["Sayan Nandan <ohsayan@outlook.com>"]
edition = "2021"
name = "libsky"
version = "0.8.0-beta"
version = "0.8.0-beta.2"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

@ -2,7 +2,7 @@
authors = ["Sayan Nandan <ohsayan@outlook.com>"]
edition = "2021"
name = "skyd"
version = "0.8.0-beta"
version = "0.8.0-beta.2"
description = "Skytable is a modern NoSQL database powered by BlueQL that aims to deliver performance, scalability and flexibility with data"
license = "AGPL-3.0"

@ -24,7 +24,6 @@
*
*/
use crate::engine::mem::ZERO_BLOCK;
#[cfg(test)]
use crate::util::test_utils;
use {
@ -35,7 +34,7 @@ use {
tag::{DataTag, TagUnique},
},
idx::meta::Comparable,
mem::{self, DwordQN, SpecialPaddedWord, WordIO},
mem::{self, DwordNN, DwordQN, SpecialPaddedWord, WordIO, ZERO_BLOCK},
},
core::{
fmt,
@ -245,7 +244,10 @@ impl Hash for PrimaryIndexKey {
impl<'a> PartialEq<Lit<'a>> for PrimaryIndexKey {
fn eq(&self, key: &Lit<'a>) -> bool {
debug_assert!(key.kind().tag_unique().is_unique());
self.tag == key.kind().tag_unique() && self.virtual_block() == key.__vdata()
let pk_data = self.data.dwordnn_load_qw();
let lit_data = unsafe { key.data() }.dwordnn_load_qw();
((self.tag == key.kind().tag_unique()) & (pk_data == lit_data))
&& self.virtual_block() == key.__vdata()
}
}
@ -283,6 +285,22 @@ impl fmt::Debug for PrimaryIndexKey {
}
}
#[test]
fn gh_issue_test_325_same_type_collapse() {
assert_ne!(
PrimaryIndexKey::try_from_dc(Datacell::new_uint_default(1)).unwrap(),
PrimaryIndexKey::try_from_dc(Datacell::new_uint_default(11)).unwrap()
);
assert_ne!(
PrimaryIndexKey::try_from_dc(Datacell::new_uint_default(1)).unwrap(),
Lit::new_uint(11)
);
assert_ne!(
PrimaryIndexKey::try_from_dc(Datacell::new_uint_default(11)).unwrap(),
Lit::new_uint(1)
);
}
#[test]
fn check_pk_wrong_type() {
let data = [

@ -2,7 +2,7 @@
authors = ["Sayan Nandan <ohsayan@outlook.com>"]
edition = "2021"
name = "sky-bench"
version = "0.8.0-beta"
version = "0.8.0-beta.2"
description = "The Skytable benchmark tool can be used to benchmark Skytable installations"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

@ -1,4 +1,4 @@
sky-bench 0.8.0-beta
sky-bench 0.8.0-beta.2
Sayan N. <ohsayan@outlook.com>
Skytable benchmark tool

@ -2,7 +2,7 @@
authors = ["Sayan Nandan <ohsayan@outlook.com>"]
edition = "2021"
name = "sky_macros"
version = "0.8.0-beta"
version = "0.8.0-beta.2"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Loading…
Cancel
Save