[pbs-devel] [PATCH proxmox-backup 2/3] Userid: fix borrow/deref recursion
Fabian Grünbichler
f.gruenbichler at proxmox.com
Thu Oct 8 15:37:19 CEST 2020
not triggered by any current code, but this would lead to a stack
exhaustion since borrow would call deref which would call borrow again..
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
src/api2/types/userid.rs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/api2/types/userid.rs b/src/api2/types/userid.rs
index f0a61031..44cd10b7 100644
--- a/src/api2/types/userid.rs
+++ b/src/api2/types/userid.rs
@@ -131,13 +131,13 @@ impl std::ops::Deref for Username {
impl Borrow<UsernameRef> for Username {
fn borrow(&self) -> &UsernameRef {
- UsernameRef::new(self.as_str())
+ UsernameRef::new(self.0.as_str())
}
}
impl AsRef<UsernameRef> for Username {
fn as_ref(&self) -> &UsernameRef {
- UsernameRef::new(self.as_str())
+ self.borrow()
}
}
@@ -204,13 +204,13 @@ impl std::ops::Deref for Realm {
impl Borrow<RealmRef> for Realm {
fn borrow(&self) -> &RealmRef {
- RealmRef::new(self.as_str())
+ RealmRef::new(self.0.as_str())
}
}
impl AsRef<RealmRef> for Realm {
fn as_ref(&self) -> &RealmRef {
- RealmRef::new(self.as_str())
+ self.borrow()
}
}
--
2.20.1
More information about the pbs-devel
mailing list