xattr: use checked_mul to increase size
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
		@ -22,8 +22,7 @@ pub fn flistxattr(fd: RawFd) -> Result<Vec<u8>, nix::errno::Errno> {
 | 
				
			|||||||
        match err {
 | 
					        match err {
 | 
				
			||||||
            Errno::ERANGE => {
 | 
					            Errno::ERANGE => {
 | 
				
			||||||
                // Buffer was not big enough to fit the list, retry with double the size
 | 
					                // Buffer was not big enough to fit the list, retry with double the size
 | 
				
			||||||
                if size * 2 < size { return Err(Errno::ENOMEM); }
 | 
					                size = size.checked_mul(2).ok_or(Errno::ENOMEM)?;
 | 
				
			||||||
                size *= 2;
 | 
					 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            _ => return Err(err),
 | 
					            _ => return Err(err),
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -49,8 +48,7 @@ pub fn fgetxattr(fd: RawFd, name: &[u8]) -> Result<Vec<u8>, nix::errno::Errno> {
 | 
				
			|||||||
        match err {
 | 
					        match err {
 | 
				
			||||||
            Errno::ERANGE => {
 | 
					            Errno::ERANGE => {
 | 
				
			||||||
                // Buffer was not big enough to fit the value, retry with double the size
 | 
					                // Buffer was not big enough to fit the value, retry with double the size
 | 
				
			||||||
                if size * 2 < size { return Err(Errno::ENOMEM); }
 | 
					                size = size.checked_mul(2).ok_or(Errno::ENOMEM)?;
 | 
				
			||||||
                size *= 2;
 | 
					 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            _ => return Err(err),
 | 
					            _ => return Err(err),
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user