Set_program_directory(): check return value of readlink()
This commit is contained in:
		
							parent
							
								
									c55c41fe83
								
							
						
					
					
						commit
						91e6796b92
					
				@ -106,10 +106,12 @@ void Set_program_directory(const char * argv0, char * program_dir)
 | 
				
			|||||||
  if (argv0[0]!='/')
 | 
					  if (argv0[0]!='/')
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    char path[PATH_MAX];
 | 
					    char path[PATH_MAX];
 | 
				
			||||||
    readlink("/proc/self/exe", path, sizeof(path));
 | 
					    if (readlink("/proc/self/exe", path, sizeof(path)) >= 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
      Extract_path(program_dir, path);
 | 
					      Extract_path(program_dir, path);
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					  }  
 | 
				
			||||||
  Extract_path(program_dir, argv0);
 | 
					  Extract_path(program_dir, argv0);
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  // Others: The part of argv[0] before the executable name.    
 | 
					  // Others: The part of argv[0] before the executable name.    
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user