Просмотр исходного кода

dpkg: Make fd variable passed to cu_closefd static

The push_cleanup() call takes a pointer to the fd variable which resides
in the stack. In case of error and stack unwinding due to longjmp, the
value of fd might get overwritten by subsequent stack usage. Thus this
kind of variables need to be static so that their value cannot change
on stack rollback.
Guillem Jover лет назад: 15
Родитель
Сommit
d6f176b4b8
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      src/filesdb.c

+ 1 - 1
src/filesdb.c

@@ -276,7 +276,7 @@ pkg_files_add_file(struct pkginfo *pkg, const char *filename,
 void
 ensure_packagefiles_available(struct pkginfo *pkg)
 {
-  int fd;
+  static int fd;
   const char *filelistfile;
   struct fileinlist **lendp;
   struct stat stat_buf;