mirror of
				https://github.com/RetroShare/RetroShare.git
				synced 2025-11-03 15:29:02 -05:00 
			
		
		
		
	Print a warning if deserialized rstime_t is negative
This commit is contained in:
		
							parent
							
								
									a89c29030a
								
							
						
					
					
						commit
						a47eec14e4
					
				
					 1 changed files with 10 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -26,8 +26,10 @@
 | 
			
		|||
#include "retroshare/rstypes.h"
 | 
			
		||||
#include "serialiser/rsbaseserial.h"
 | 
			
		||||
#include "util/rsnet.h"
 | 
			
		||||
#include "util/rstime.h"
 | 
			
		||||
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <cstdint>
 | 
			
		||||
 | 
			
		||||
/* UInt8 get/set */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -289,11 +291,15 @@ bool setRawString(void *data, uint32_t size, uint32_t *offset, const std::string
 | 
			
		|||
 | 
			
		||||
bool getRawTimeT(const void *data,uint32_t size,uint32_t *offset,rstime_t& t)
 | 
			
		||||
{
 | 
			
		||||
	uint64_t T ;
 | 
			
		||||
	bool res = getRawUInt64(data,size,offset,&T) ;
 | 
			
		||||
	t = T ;
 | 
			
		||||
	uint64_t T;
 | 
			
		||||
	bool res = getRawUInt64(data,size,offset,&T);
 | 
			
		||||
	t = T;
 | 
			
		||||
 | 
			
		||||
	return res ;
 | 
			
		||||
	if(t < 0) // [[unlikely]]
 | 
			
		||||
		std::cerr << __PRETTY_FUNCTION__ << " got a negative time: " << t
 | 
			
		||||
		          << " this seems fishy, report to the developers!" << std::endl;
 | 
			
		||||
 | 
			
		||||
	return res;
 | 
			
		||||
}
 | 
			
		||||
bool setRawTimeT(void *data, uint32_t size, uint32_t *offset, const rstime_t& t)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue