mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	object.c: fix potential oob write in rb_str_to_dbl()
Ensure space for the terminating NUL byte. Note that this code path is reachable only when Ruby is compiled with SHARABLE_MIDDLE_SUBSTRING=1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									99d64640c4
								
							
						
					
					
						commit
						fc188f1646
					
				
					 1 changed files with 1 additions and 1 deletions
				
			
		
							
								
								
									
										2
									
								
								object.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								object.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -3302,7 +3302,7 @@ rb_str_to_dbl(VALUE str, int badcheck)
 | 
			
		|||
	    rb_raise(rb_eArgError, "string for Float contains null byte");
 | 
			
		||||
	}
 | 
			
		||||
	if (s[len]) {		/* no sentinel somehow */
 | 
			
		||||
	    char *p =  ALLOCV(v, len);
 | 
			
		||||
	    char *p = ALLOCV(v, (size_t)len + 1);
 | 
			
		||||
	    MEMCPY(p, s, char, len);
 | 
			
		||||
	    p[len] = '\0';
 | 
			
		||||
	    s = p;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue