SHA256
1
0
forked from pool/file

Accepting request 233546 from Base:System

- file-secure_getenv.patch use secure_getenv only as we 
  can't know in which context the shared library is used. (forwarded request 233200 from elvigia)

OBS-URL: https://build.opensuse.org/request/show/233546
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/file?expand=0&rev=81
This commit is contained in:
Stephan Kulow 2014-05-22 18:37:58 +00:00 committed by Git OBS Bridge
commit 09b98fd663
3 changed files with 85 additions and 0 deletions

77
file-secure_getenv.patch Normal file
View File

@ -0,0 +1,77 @@
--- file-5.18.orig/configure.ac
+++ file-5.18/configure.ac
@@ -86,6 +86,8 @@ AC_CHECK_HEADERS(getopt.h err.h)
AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h)
AC_CHECK_HEADERS(zlib.h)
+AC_CHECK_FUNCS([__secure_getenv secure_getenv])
+
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_OFF_T
--- file-5.18.orig/src/file.h
+++ file-5.18/src/file.h
@@ -541,4 +541,12 @@ static const char *rcsid(const char *p)
#define FILE_RCSID(id)
#endif
+#ifndef HAVE_SECURE_GETENV
+# ifdef HAVE___SECURE_GETENV
+# define secure_getenv __secure_getenv
+# else
+# error neither secure_getenv nor __secure_getenv is available
+# endif
+#endif
+
#endif /* __file_h__ */
--- file-5.18.orig/src/magic.c
+++ file-5.18/src/magic.c
@@ -97,7 +97,7 @@ get_default_magic(void)
free(default_magic);
default_magic = NULL;
}
- if ((home = getenv("HOME")) == NULL)
+ if ((home = secure_getenv("HOME")) == NULL)
return MAGIC;
if (asprintf(&hmagicpath, "%s/.magic.mgc", home) < 0)
@@ -152,8 +152,8 @@ out:
}
/* First, try to get user-specific magic file */
- if ((home = getenv("LOCALAPPDATA")) == NULL) {
- if ((home = getenv("USERPROFILE")) != NULL)
+ if ((home = secure_getenv("LOCALAPPDATA")) == NULL) {
+ if ((home = secure_getenv("USERPROFILE")) != NULL)
if (asprintf(&tmppath,
"%s/Local Settings/Application Data%s", home,
hmagic) < 0)
@@ -166,7 +166,7 @@ out:
APPENDPATH();
/* Second, try to get a magic file from Common Files */
- if ((home = getenv("COMMONPROGRAMFILES")) != NULL) {
+ if ((home = secure_getenv("COMMONPROGRAMFILES")) != NULL) {
if (asprintf(&tmppath, "%s%s", home, hmagic) >= 0)
APPENDPATH();
}
@@ -204,7 +204,7 @@ magic_getpath(const char *magicfile, int
if (magicfile != NULL)
return magicfile;
- magicfile = getenv("MAGIC");
+ magicfile = secure_getenv("MAGIC");
if (magicfile != NULL)
return magicfile;
--- file-5.18.orig/src/file.c
+++ file-5.18/src/file.c
@@ -530,7 +530,7 @@ docprint(const char *opts)
private void
help(void)
{
- const unsigned long posix = (unsigned long)getenv("POSIXLY_CORRECT");
+ const unsigned long posix = (unsigned long)secure_getenv("POSIXLY_CORRECT");
(void)fputs(
"Usage: file [OPTION...] [FILE...]\n"
"Determine type of FILEs.\n"

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu May 8 19:56:07 UTC 2014 - crrodriguez@opensuse.org
- file-secure_getenv.patch use secure_getenv only as we
can't know in which context the shared library is used.
------------------------------------------------------------------- -------------------------------------------------------------------
Fri Mar 28 10:24:18 UTC 2014 - werner@suse.de Fri Mar 28 10:24:18 UTC 2014 - werner@suse.de

View File

@ -61,6 +61,7 @@ Patch33: file-5.16-ocloexec.patch
Patch34: file-5.18-endian.patch Patch34: file-5.18-endian.patch
Patch35: file-5.12-nitpick.dif Patch35: file-5.12-nitpick.dif
Patch36: file-5.15-clear-invalid.patch Patch36: file-5.15-clear-invalid.patch
Patch37: file-secure_getenv.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
%global _sysconfdir /etc %global _sysconfdir /etc
%global _miscdir %{_datadir}/misc %global _miscdir %{_datadir}/misc
@ -126,6 +127,7 @@ to develop applications that require the magic "file" interface.
%patch34 -p0 -b .endian %patch34 -p0 -b .endian
%patch35 -p0 -b .nitpick %patch35 -p0 -b .nitpick
%patch36 -p1 -b .clear %patch36 -p1 -b .clear
%patch37 -p1 -b .getenv
%patch -b .0 %patch -b .0
test -s src/magic.h.in || cp -p src/magic.h src/magic.h.in test -s src/magic.h.in || cp -p src/magic.h src/magic.h.in