mirror of
				https://review.coreboot.org/flashrom.git
				synced 2025-11-04 07:00:39 +01:00 
			
		
		
		
	ich_descriptors.c: Ensure unsigned types >=0 on to prevent underflow
Unsigned types show undefined behaviour if they are subtracted by a value greater than their own (mostly it wraps to the max value). Using this value for left shifting could be even more dangerous. Change-Id: I5921cc571f3dca5188ca1973dba6ececbcbe2f39 Signed-off-by: Aarya Chaumal <aarya.chaumal@gmail.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/62764 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
		
				
					committed by
					
						
						Anastasia Klimchuk
					
				
			
			
				
	
			
			
			
						parent
						
							950037a724
						
					
				
				
					commit
					7273274e00
				
			@@ -502,16 +502,17 @@ void prettyprint_ich_descriptor_master(const enum ich_chipset cs, const struct i
 | 
				
			|||||||
			msg_pdbg2(" RegA RegB RegC RegD RegE RegF\n");
 | 
								msg_pdbg2(" RegA RegB RegC RegD RegE RegF\n");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		for (i = 0; i < nm; i++) {
 | 
							for (i = 0; i < nm; i++) {
 | 
				
			||||||
 | 
								const unsigned int ext_region_start = 12;
 | 
				
			||||||
			size_t j;
 | 
								size_t j;
 | 
				
			||||||
			msg_pdbg2("%-4s", master_names[i]);
 | 
								msg_pdbg2("%-4s", master_names[i]);
 | 
				
			||||||
			for (j = 0; j < (size_t)min(num_regions, 12); j++)
 | 
								for (j = 0; j < (size_t)min(num_regions, ext_region_start); j++)
 | 
				
			||||||
				msg_pdbg2("  %c%c ",
 | 
									msg_pdbg2("  %c%c ",
 | 
				
			||||||
					  desc->master.mstr[i].read & (1 << j) ? 'r' : ' ',
 | 
										  desc->master.mstr[i].read & (1 << j) ? 'r' : ' ',
 | 
				
			||||||
					  desc->master.mstr[i].write & (1 << j) ? 'w' : ' ');
 | 
										  desc->master.mstr[i].write & (1 << j) ? 'w' : ' ');
 | 
				
			||||||
			for (; j < num_regions; j++)
 | 
								for (j = ext_region_start; j < num_regions; j++)
 | 
				
			||||||
				msg_pdbg2("  %c%c ",
 | 
									msg_pdbg2("  %c%c ",
 | 
				
			||||||
					  desc->master.mstr[i].ext_read & (1 << (j - 12)) ? 'r' : ' ',
 | 
										  desc->master.mstr[i].ext_read & (1 << (j - ext_region_start)) ? 'r' : ' ',
 | 
				
			||||||
					  desc->master.mstr[i].ext_write & (1 << (j - 12)) ? 'w' : ' ');
 | 
										  desc->master.mstr[i].ext_write & (1 << (j - ext_region_start)) ? 'w' : ' ');
 | 
				
			||||||
			msg_pdbg2("\n");
 | 
								msg_pdbg2("\n");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else if (cs == CHIPSET_C620_SERIES_LEWISBURG) {
 | 
						} else if (cs == CHIPSET_C620_SERIES_LEWISBURG) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user