Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 308681 Details for
Bug 411785
app-misc/uptimed loses its database
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch from Debian Sid
thibaut-truc-detect-corrupt-configuration-file-fixed-filesize-comparison.patch (text/plain), 2.00 KB, created by
jjtt
on 2012-04-12 18:37:03 UTC
(
hide
)
Description:
patch from Debian Sid
Filename:
MIME Type:
Creator:
jjtt
Created:
2012-04-12 18:37:03 UTC
Size:
2.00 KB
patch
obsolete
>diff -Nru uptimed-0.3.16.orig/libuptimed/urec.c uptimed-0.3.16/libuptimed/urec.c >--- uptimed-0.3.16.orig/libuptimed/urec.c 2009-01-02 00:46:00.000000000 +0100 >+++ uptimed-0.3.16/libuptimed/urec.c 2011-03-06 21:01:28.000000000 +0100 >@@ -215,20 +215,46 @@ > time_t utime, btime; > long l_utime, l_btime; > char buf[256], sys[SYSMAX+1]; >+ struct stat filestat, filestatold; >+ int useold = 0; > >- f = fopen(FILE_RECORDS, "r"); >- if (!f) { >- f = fopen(FILE_RECORDS".old", "r"); >- if (!f) return; >+ if (stat(FILE_RECORDS, &filestat)) >+ useold = 1; >+ if (stat(FILE_RECORDS".old", &filestatold)) >+ useold = -1; >+ >+ /* assume that backupdb larger than normal db means normal is corrupted */ >+ if (!useold && (filestat.st_size < filestatold.st_size)) >+ useold = 1; > >- printf("uptimed: reading from backup database %s.old\n", FILE_RECORDS); >+dbtry: >+ switch (useold) { >+ case 0: >+ f = fopen(FILE_RECORDS, "r"); >+ break; >+ case 1: >+ f = fopen(FILE_RECORDS".old", "r"); >+ printf("uptimed: reading from backup database %s.old\n", FILE_RECORDS); >+ break; >+ default: >+ /* this should probably terminate uptimed somehow */ >+ printf("uptimed: no useable database found.\n"); >+ return; >+ } >+ >+ if (!f) { >+ printf("uptimed: error opening database for reading.\n"); >+ return; > } > > fgets(str, sizeof(str), f); > while (!feof(f)) { > /* Check for validity of input string. */ > if (sscanf(str, "%ld:%ld:%[^]\n]", &l_utime, &l_btime, buf) != 3) { >- /* Skip this entry. Do we want feedback here? */ >+ /* database is corrupted */ >+ fclose(f); >+ useold++; >+ goto dbtry; > } else { > utime = (time_t)l_utime; > btime = (time_t)l_btime; >diff -Nru uptimed-0.3.16.orig/libuptimed/urec.h uptimed-0.3.16/libuptimed/urec.h >--- uptimed-0.3.16.orig/libuptimed/urec.h 2009-01-02 00:46:00.000000000 +0100 >+++ uptimed-0.3.16/libuptimed/urec.h 2011-03-06 20:48:49.000000000 +0100 >@@ -21,6 +21,7 @@ > #include <string.h> > #include <stdlib.h> > #include <sys/types.h> >+#include <sys/stat.h> > > #ifdef PLATFORM_LINUX > #include <sys/sysinfo.h>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 411785
: 308681 |
308687
|
308689