port: Prevent undefined shift operations in msg_current().
Adjust checks of logMessageInterval in received packet to prevent 1 of type int being shifted by values >= 31. Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
This commit is contained in:
		
							parent
							
								
									3c7e4947e4
								
							
						
					
					
						commit
						6d50817dc0
					
				
							
								
								
									
										4
									
								
								port.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								port.c
									
									
									
									
									
								
							@ -140,9 +140,9 @@ static int msg_current(struct ptp_message *m, struct timespec now)
 | 
				
			|||||||
	t1 = m->ts.host.tv_sec * NSEC2SEC + m->ts.host.tv_nsec;
 | 
						t1 = m->ts.host.tv_sec * NSEC2SEC + m->ts.host.tv_nsec;
 | 
				
			||||||
	t2 = now.tv_sec * NSEC2SEC + now.tv_nsec;
 | 
						t2 = now.tv_sec * NSEC2SEC + now.tv_nsec;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (m->header.logMessageInterval < -63) {
 | 
						if (m->header.logMessageInterval <= -31) {
 | 
				
			||||||
		tmo = 0;
 | 
							tmo = 0;
 | 
				
			||||||
	} else if (m->header.logMessageInterval > 31) {
 | 
						} else if (m->header.logMessageInterval >= 31) {
 | 
				
			||||||
		tmo = INT64_MAX;
 | 
							tmo = INT64_MAX;
 | 
				
			||||||
	} else if (m->header.logMessageInterval < 0) {
 | 
						} else if (m->header.logMessageInterval < 0) {
 | 
				
			||||||
		tmo = 4LL * NSEC2SEC / (1 << -m->header.logMessageInterval);
 | 
							tmo = 4LL * NSEC2SEC / (1 << -m->header.logMessageInterval);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user