]> git.proxmox.com Git - proxmox-backup.git/commitdiff
Userid: fix borrow/deref recursion
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 8 Oct 2020 13:37:19 +0000 (15:37 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 8 Oct 2020 13:57:10 +0000 (15:57 +0200)
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@proxmox.com>
src/api2/types/userid.rs

index f0a61031d145dd87c526a6ff2d408f61d111bac8..44cd10b767fa58d3a2a1c30555add0f85ec9155e 100644 (file)
@@ -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()
     }
 }