mirror of
				git://git.code.sf.net/p/cdesktopenv/code
				synced 2025-03-09 15:50:02 +00:00 
			
		
		
		
	Fix a potential read of uninitialized memory through a pointer
src/lib/libast/misc/magic.c: - Use strncpy instead of memcpy to avoid reading past the null terminator of the string pointed to by p.
This commit is contained in:
		
							parent
							
								
									3224b79083
								
							
						
					
					
						commit
						a9e7012dfd
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
					@ -687,8 +687,8 @@ ckmagic(register Magic_t* mp, const char* file, char* buf, char* end, struct sta
 | 
				
			||||||
				c = mp->fbsz;
 | 
									c = mp->fbsz;
 | 
				
			||||||
				if (c >= sizeof(mp->nbuf))
 | 
									if (c >= sizeof(mp->nbuf))
 | 
				
			||||||
					c = sizeof(mp->nbuf) - 1;
 | 
										c = sizeof(mp->nbuf) - 1;
 | 
				
			||||||
				p = (char*)memcpy(mp->nbuf, p, c);
 | 
									p = strncpy(mp->nbuf, p, c);
 | 
				
			||||||
				p[c] = 0;
 | 
									p[c] = '\0';
 | 
				
			||||||
				ccmapstr(mp->x2n, p, c);
 | 
									ccmapstr(mp->x2n, p, c);
 | 
				
			||||||
				if ((c = regexec(ep->value.sub, p, elementsof(matches), matches, 0)) || (c = regsubexec(ep->value.sub, p, elementsof(matches), matches)))
 | 
									if ((c = regexec(ep->value.sub, p, elementsof(matches), matches, 0)) || (c = regsubexec(ep->value.sub, p, elementsof(matches), matches)))
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue