mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Make sure that *really* no more than sizeof(ifr.ifr_name) chars are strcpy-ed to ifr.ifr_name and that the string is *always* NUL terminated. New code shouldn't use strcpy(), too. CID 719692
This commit is contained in:
		
							parent
							
								
									1b3f3b0316
								
							
						
					
					
						commit
						15b6885fe0
					
				
					 1 changed files with 2 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -1674,7 +1674,8 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
 | 
			
		|||
            if (len == 0) {
 | 
			
		||||
                ifr.ifr_ifindex = 0;
 | 
			
		||||
            } else if (len < sizeof(ifr.ifr_name)) {
 | 
			
		||||
                strcpy(ifr.ifr_name, PyBytes_AS_STRING(interfaceName));
 | 
			
		||||
                strncpy(ifr.ifr_name, PyBytes_AS_STRING(interfaceName), sizeof(ifr.ifr_name));
 | 
			
		||||
                ifr.ifr_name[(sizeof(ifr.ifr_name))-1] = '\0';
 | 
			
		||||
                if (ioctl(s->sock_fd, SIOCGIFINDEX, &ifr) < 0) {
 | 
			
		||||
                    s->errorhandler();
 | 
			
		||||
                    Py_DECREF(interfaceName);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue