Resolves: rhbz#759647 temp file name collision
This commit is contained in:
parent
2a6317baa7
commit
5465ec7811
74
hunspell.rhbz759647.patch
Normal file
74
hunspell.rhbz759647.patch
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
Index: src/tools/hunspell.cxx
|
||||||
|
===================================================================
|
||||||
|
RCS file: /cvsroot/hunspell/hunspell/src/tools/hunspell.cxx,v
|
||||||
|
retrieving revision 1.28
|
||||||
|
diff -u -r1.28 hunspell.cxx
|
||||||
|
--- src/tools/hunspell.cxx 21 Jan 2011 17:30:41 -0000 1.28
|
||||||
|
+++ src/tools/hunspell.cxx 6 Dec 2011 22:44:15 -0000
|
||||||
|
@@ -128,8 +128,6 @@
|
||||||
|
#define readline scanline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-#define TEMPNAME "hunSPELL.bak"
|
||||||
|
-
|
||||||
|
extern char * mystrdup(const char * s);
|
||||||
|
|
||||||
|
// file formats:
|
||||||
|
@@ -1316,14 +1314,12 @@
|
||||||
|
char * extension = basename(filename, '.');
|
||||||
|
parser = get_parser(format, extension, pMS[0]);
|
||||||
|
|
||||||
|
- char * tempname = (char *) malloc(strlen(filename) + strlen(TEMPNAME) + 1);
|
||||||
|
- strcpy(tempname, filename);
|
||||||
|
- strcpy(basename(tempname, DIRSEPCH), TEMPNAME);
|
||||||
|
-
|
||||||
|
- FILE *tempfile;
|
||||||
|
+
|
||||||
|
+ FILE *tempfile = tmpfile();
|
||||||
|
|
||||||
|
- if (!(tempfile = fopen(tempname, "w"))) {
|
||||||
|
- fprintf(stderr, gettext("Can't create tempfile %s.\n"), tempname);
|
||||||
|
+ if (!tempfile)
|
||||||
|
+ {
|
||||||
|
+ perror(gettext("Can't create tempfile"));
|
||||||
|
endwin();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
@@ -1337,7 +1333,7 @@
|
||||||
|
case -1: {
|
||||||
|
clear();
|
||||||
|
refresh();
|
||||||
|
- unlink(tempname);
|
||||||
|
+ fclose(tempfile); //automatically deleted when closed
|
||||||
|
endwin();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
@@ -1350,15 +1346,22 @@
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(text);
|
||||||
|
- fclose(tempfile);
|
||||||
|
delete parser;
|
||||||
|
|
||||||
|
- if (! modified) {
|
||||||
|
- unlink(tempname);
|
||||||
|
- } else {
|
||||||
|
- rename(tempname, filename);
|
||||||
|
+ if (modified) {
|
||||||
|
+ rewind(tempfile);
|
||||||
|
+ text = fopen(filename, "wb");
|
||||||
|
+
|
||||||
|
+ size_t n;
|
||||||
|
+ while ((n = fread(buf, 1, MAXLNLEN, tempfile)) > 0)
|
||||||
|
+ {
|
||||||
|
+ if (fwrite(buf, 1, n, text) != n)
|
||||||
|
+ perror("write failed");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ fclose(text);
|
||||||
|
}
|
||||||
|
- free(tempname);
|
||||||
|
+ fclose(tempfile); //automatically deleted when closed
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -3,7 +3,7 @@
|
|||||||
Name: hunspell
|
Name: hunspell
|
||||||
Summary: A spell checker and morphological analyzer library
|
Summary: A spell checker and morphological analyzer library
|
||||||
Version: 1.3.2
|
Version: 1.3.2
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
Source: http://downloads.sourceforge.net/%{name}/hunspell-%{version}.tar.gz
|
Source: http://downloads.sourceforge.net/%{name}/hunspell-%{version}.tar.gz
|
||||||
Group: System Environment/Libraries
|
Group: System Environment/Libraries
|
||||||
URL: http://hunspell.sourceforge.net/
|
URL: http://hunspell.sourceforge.net/
|
||||||
@ -16,6 +16,7 @@ BuildRequires: valgrind
|
|||||||
%if %{double_profiling_build}
|
%if %{double_profiling_build}
|
||||||
BuildRequires: words
|
BuildRequires: words
|
||||||
%endif
|
%endif
|
||||||
|
Patch0: hunspell.rhbz759647.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Hunspell is a spell checker and morphological analyzer library and program
|
Hunspell is a spell checker and morphological analyzer library and program
|
||||||
@ -33,6 +34,7 @@ Includes and definitions for developing with hunspell
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
|
%patch0 -p0 -b .rhbz759647
|
||||||
|
|
||||||
%build
|
%build
|
||||||
configureflags="--disable-rpath --disable-static --with-ui --with-readline"
|
configureflags="--disable-rpath --disable-static --with-ui --with-readline"
|
||||||
@ -121,6 +123,9 @@ rm -rf $RPM_BUILD_ROOT
|
|||||||
%{_mandir}/man3/hunspell.3.gz
|
%{_mandir}/man3/hunspell.3.gz
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Dec 06 2011 Caolán McNamara <caolanm@redhat.com> - 1.3.2-2
|
||||||
|
- Resolves: rhbz#759647 temp file name collision
|
||||||
|
|
||||||
* Tue May 24 2011 Caolán McNamara <caolanm@redhat.com> - 1.3.2-1
|
* Tue May 24 2011 Caolán McNamara <caolanm@redhat.com> - 1.3.2-1
|
||||||
- Resolves: rhbz#706686 latest version
|
- Resolves: rhbz#706686 latest version
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user