test for write error on fclose (#1166882)

- also drop unnecessary and broken nowrap patch
This commit is contained in:
Tomas Mraz 2014-11-24 15:35:59 +01:00
parent 7ca7f064c8
commit 4fe15d5740
3 changed files with 32 additions and 15 deletions

View File

@ -1,12 +0,0 @@
diff -up at-3.1.14/at.c.wrap at-3.1.14/at.c
--- at-3.1.14/at.c.wrap 2013-12-02 15:42:10.000000000 +0100
+++ at-3.1.14/at.c 2013-12-02 15:45:42.679092990 +0100
@@ -304,7 +304,7 @@ writefile(time_t runtimer, char queue)
if (*ap == ' ')
*ap = '0';
- if (stat(atfile, &statbuf) != 0)
+ /*if (stat(atfile, &statbuf) != 0)
if (errno != ENOENT)
perr("Cannot access " ATJOB_DIR);

View File

@ -0,0 +1,26 @@
diff -up at-3.1.16/at.c.fclose at-3.1.16/at.c
--- at-3.1.16/at.c.fclose 2014-11-06 16:11:28.000000000 +0100
+++ at-3.1.16/at.c 2014-11-24 15:30:12.704502966 +0100
@@ -209,7 +209,11 @@ nextjob()
jobno = (1 + jobno) % 0xfffff; /* 2^20 jobs enough? */
fprintf(fid, "%05lx\n", jobno);
- fclose(fid);
+ if (ferror(fid))
+ jobno = EOF;
+
+ if (fclose(fid) != 0)
+ jobno = EOF;
return jobno;
}
@@ -494,7 +498,8 @@ writefile(time_t runtimer, char queue)
if (ferror(stdin))
panic("Input error");
- fclose(fp);
+ if (fclose(fp) != 0)
+ panic("Output error");
/* Set the x bit so that we're ready to start executing
*/

View File

@ -3,7 +3,7 @@
Summary: Job spooling tools
Name: at
Version: 3.1.16
Release: 3%{?dist}
Release: 4%{?dist}
# http://packages.debian.org/changelogs/pool/main/a/at/current/copyright
# + install-sh is MIT license with changes under Public Domain
License: GPLv3+ and GPLv2+ and ISC and MIT and Public Domain
@ -23,13 +23,13 @@ Patch3: at-3.1.14-selinux.patch
Patch4: at-3.1.14-opt_V.patch
Patch5: at-3.1.14-shell.patch
Patch6: at-3.1.14-nitpicks.patch
Patch7: at-3.1.14-nowrap.patch
Patch8: at-3.1.14-fix_no_export.patch
Patch9: at-3.1.14-mailwithhostname.patch
Patch10: at-3.1.14-usePOSIXtimers.patch
Patch11: at-3.1.14-help.patch
Patch12: at-3.1.14-wrong_format.patch
Patch13: at-3.1.16-noabort.patch
Patch14: at-3.1.16-fclose-error.patch
BuildRequires: fileutils /etc/init.d
BuildRequires: flex flex-static bison autoconf
@ -72,13 +72,13 @@ cp %{SOURCE1} .
%patch4 -p1 -b .opt_V
%patch5 -p1 -b .shell
%patch6 -p1 -b .nit
%patch7 -p1 -b .nowrap
%patch8 -p1 -b .export
%patch9 -p1 -b .mail
%patch10 -p1 -b .posix
%patch11 -p1 -b .help
%patch12 -p1 -b .wrong
%patch13 -p1 -b .noabort
%patch14 -p1 -b .fclose
%build
# patch9 touches configure.in
@ -176,6 +176,9 @@ chown daemon:daemon %{_localstatedir}/spool/at/.SEQ
%attr(0644,root,root) /%{_unitdir}/atd.service
%changelog
* Mon Nov 24 2014 Tomáš Mráz <tmraz@redhat.com> - 3.1.16-4
- test for write error on fclose (#1166882)
* Thu Nov 6 2014 Tomáš Mráz <tmraz@redhat.com> - 3.1.16-3
- make atd less abort prone