mirror of
				https://github.com/PurpleI2P/i2pd.git
				synced 2025-11-04 08:30:46 +00:00 
			
		
		
		
	* bounds check on Identity::FromBuffer
* properly indet last commits
This commit is contained in:
		
							parent
							
								
									21090eaa39
								
							
						
					
					
						commit
						d4febb4e84
					
				
					 1 changed files with 9 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -22,6 +22,10 @@ namespace data
 | 
			
		|||
 | 
			
		||||
	size_t Identity::FromBuffer (const uint8_t * buf, size_t len)
 | 
			
		||||
	{
 | 
			
		||||
		if ( len < DEFAULT_IDENTITY_SIZE ) {
 | 
			
		||||
			// buffer too small, don't overflow
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
		memcpy (publicKey, buf, DEFAULT_IDENTITY_SIZE);
 | 
			
		||||
		return DEFAULT_IDENTITY_SIZE;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -245,7 +249,7 @@ namespace data
 | 
			
		|||
		const size_t slen = s.length();
 | 
			
		||||
		const size_t bufLen = Base64EncodingBufferSize(slen);
 | 
			
		||||
		uint8_t buf[bufLen];
 | 
			
		||||
		auto len = Base64ToByteStream (s.c_str(), slen, buf, 1024);
 | 
			
		||||
		const size_t len = Base64ToByteStream (s.c_str(), slen, buf, bufLen);
 | 
			
		||||
		return FromBuffer (buf, len);
 | 
			
		||||
	}	
 | 
			
		||||
	
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue