mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-07 15:15:59 +01:00
Prevent buffer overflow in realpath
This patch prevents a buffer overflow in the realpath function. Thanks to Abel Abraham Camarillo Ojeda
This commit is contained in:
parent
af1f0f9dac
commit
6d3bce6920
1 changed files with 17 additions and 1 deletions
18
zathura.c
18
zathura.c
|
@ -898,8 +898,24 @@ open_file(char* path, char* password)
|
|||
{
|
||||
g_static_mutex_lock(&(Zathura.Lock.pdf_obj_lock));
|
||||
|
||||
/* specify path max */
|
||||
size_t pm;
|
||||
#ifdef PATH_MAX
|
||||
pm = PATH_MAX;
|
||||
#else
|
||||
pm = pathconf(path,_PC_PATH_MAX);
|
||||
if(pm <= 0)
|
||||
pm = 4096;
|
||||
#endif
|
||||
|
||||
/* get filename */
|
||||
char* file = realpath(path, NULL);
|
||||
char* file = (char*) calloc(sizeof(char), pm);
|
||||
if(!file || !realpath(path, file))
|
||||
{
|
||||
if(file)
|
||||
free(file);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(path[0] == '~')
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue