Changeset 251
- Timestamp:
- 05/05/11 21:34:35 (14 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/regfi.h
r250 r251 191 191 */ 192 192 /* Minimum time is Jan 1, 1990 00:00:00 */ 193 #define REGFI_MTIME_MIN _HIGH 0x01B41E6D193 #define REGFI_MTIME_MIN 0x01B41E6D00000000L 194 194 195 195 /* Maximum time is Jan 1, 2290 00:00:00 196 196 * (We hope no one is using Windows by then...) 197 197 */ 198 #define REGFI_MTIME_MAX _HIGH 0x03047543198 #define REGFI_MTIME_MAX 0x0304754300000000L 199 199 200 200 … … 270 270 : ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1)) 271 271 #define TIME_T_MAX (~ (time_t) 0 - TIME_T_MIN) 272 #define TIME_FIXUP_CONSTANT(369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60))272 #define REGFI_TIME_FIXUP (369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60)) 273 273 274 274 … … 278 278 /******************************************************************************/ 279 279 280 typedef struct _regfi_nttime 281 { 282 uint32_t low; 283 uint32_t high; 284 } REGFI_NTTIME; 285 280 typedef uint64_t REGFI_NTTIME; 286 281 287 282 typedef struct _regfi_log … … 1731 1726 /* XXX: move to base API and document */ 1732 1727 _EXPORT() 1733 void regfi_unix2nt_time(REGFI_NTTIME* nt,time_t t);1734 _EXPORT() 1735 double regfi_nt2unix_time( const REGFI_NTTIME*nt);1728 REGFI_NTTIME regfi_unix2nt_time(time_t t); 1729 _EXPORT() 1730 double regfi_nt2unix_time(REGFI_NTTIME nt); 1736 1731 1737 1732 -
trunk/lib/regfi.c
r250 r251 2753 2753 ret_val->sequence1 = IVAL(file_header, 0x4); 2754 2754 ret_val->sequence2 = IVAL(file_header, 0x8); 2755 ret_val->mtime .low = IVAL(file_header, 0xC);2756 ret_val->mtime .high = IVAL(file_header, 0x10);2755 ret_val->mtime = ((uint64_t)IVAL(file_header, 0x10)) << 32; 2756 ret_val->mtime |= IVAL(file_header, 0xC); 2757 2757 ret_val->major_version = IVAL(file_header, 0x14); 2758 2758 ret_val->minor_version = IVAL(file_header, 0x18); … … 2936 2936 } 2937 2937 2938 ret_val->mtime .low = IVAL(nk_header, 0x4);2939 ret_val->mtime .high = IVAL(nk_header, 0x8);2938 ret_val->mtime = ((uint64_t)IVAL(nk_header, 0x8)) << 32; 2939 ret_val->mtime |= IVAL(nk_header, 0x4); 2940 2940 /* If the key is unallocated and the MTIME is earlier than Jan 1, 1990 2941 2941 * or later than Jan 1, 2290, we consider this a bad key. This helps … … 2943 2943 */ 2944 2944 if(unalloc 2945 && (ret_val->mtime .high < REGFI_MTIME_MIN_HIGH2946 || ret_val->mtime .high > REGFI_MTIME_MAX_HIGH))2945 && (ret_val->mtime < REGFI_MTIME_MIN 2946 || ret_val->mtime > REGFI_MTIME_MAX)) 2947 2947 { goto fail_locked; } 2948 2948 … … 3794 3794 3795 3795 /**************************************************************************** 3796 Put a8 byte filetime from a time_t3796 Returns an 8 byte filetime from a time_t 3797 3797 This takes real GMT as input and converts to kludge-GMT 3798 3798 ****************************************************************************/ 3799 void regfi_unix2nt_time(REGFI_NTTIME *nt,time_t t)3799 REGFI_NTTIME regfi_unix2nt_time(time_t t) 3800 3800 { 3801 3801 double d; 3802 3803 if (t==0) 3804 { 3805 nt->low = 0; 3806 nt->high = 0; 3807 return; 3808 } 3802 3803 if (t==0) 3804 return 0L; 3809 3805 3810 3806 if (t == TIME_T_MAX) 3811 { 3812 nt->low = 0xffffffff; 3813 nt->high = 0x7fffffff; 3814 return; 3815 } 3807 return 0x7fffffffffffffffL; 3816 3808 3817 3809 if (t == -1) 3818 { 3819 nt->low = 0xffffffff; 3820 nt->high = 0xffffffff; 3821 return; 3822 } 3810 return 0xffffffffffffffffL; 3823 3811 3824 3812 /* this converts GMT to kludge-GMT */ … … 3829 3817 /* t -= TimeDiff(t) - get_serverzone(); */ 3830 3818 3831 d = (double)(t); 3832 d += TIME_FIXUP_CONSTANT; 3819 d = (double)(t) + REGFI_TIME_FIXUP; 3833 3820 d *= 1.0e7; 3834 3835 nt->high = (uint32_t)(d * (1.0/(4.0*(double)(1<<30)))); 3836 nt->low = (uint32_t)(d - ((double)nt->high)*4.0*(double)(1<<30)); 3821 /* 3822 nt->high = (uint32_t)(d * (1.0/c)); 3823 nt->low = (uint32_t)(d - ((double)nt->high) * c); 3824 */ 3825 3826 return (REGFI_NTTIME) d; 3837 3827 } 3838 3828 … … 3849 3839 converts this to real GMT. 3850 3840 ****************************************************************************/ 3851 double regfi_nt2unix_time( const REGFI_NTTIME*nt)3841 double regfi_nt2unix_time(REGFI_NTTIME nt) 3852 3842 { 3853 3843 double ret_val; 3854 3855 /* The next two lines are a fix needed for the 3856 broken SCO compiler. JRA. */ 3857 time_t l_time_min = TIME_T_MIN; 3858 time_t l_time_max = TIME_T_MAX; 3859 3860 if (nt->high == 0 || (nt->high == 0xffffffff && nt->low == 0xffffffff)) 3861 return(0); 3862 3863 ret_val = ((double)nt->high)*4.0*(double)(1<<30); 3864 ret_val += nt->low; 3865 ret_val *= 1.0e-7; 3844 3845 if (nt == 0 || nt == 0xffffffffffffffffL) 3846 return 0; 3847 3848 ret_val = (double)(nt) * 1.0e-7; 3866 3849 3867 3850 /* now adjust by 369 years to make the secs since 1970 */ 3868 ret_val -= TIME_FIXUP_CONSTANT; 3869 3870 /* XXX: should these sanity checks be removed? */ 3871 if (ret_val <= l_time_min) 3872 return (l_time_min); 3873 3874 if (ret_val >= l_time_max) 3875 return (l_time_max); 3851 ret_val -= REGFI_TIME_FIXUP; 3876 3852 3877 3853 /* this takes us from kludge-GMT to real GMT */ -
trunk/src/common.c
r232 r251 361 361 362 362 363 void formatTime( const REGFI_NTTIME*nttime, char* output)363 void formatTime(REGFI_NTTIME nttime, char* output) 364 364 { 365 365 time_t tmp_time[1]; -
trunk/src/reglookup-recover.c
r233 r251 73 73 char* quoted_raw = ""; 74 74 75 formatTime( &nk->mtime, mtime);75 formatTime(nk->mtime, mtime); 76 76 77 77 /* XXX: Add command line option to choose output encoding */ -
trunk/src/reglookup.c
r249 r251 107 107 { 108 108 cur_key = regfi_iterator_cur_key(iter); 109 *tmp_time = regfi_nt2unix_time( &cur_key->mtime);109 *tmp_time = regfi_nt2unix_time(cur_key->mtime); 110 110 tmp_time_s = gmtime(tmp_time); 111 111 strftime(mtime, sizeof(mtime), "%Y-%m-%d %H:%M:%S", tmp_time_s); … … 304 304 const REGFI_CLASSNAME* classname; 305 305 306 formatTime( &key->mtime, mtime);306 formatTime(key->mtime, mtime); 307 307 308 308 if(print_security && (sk=regfi_fetch_sk(iter->f, key)))
Note: See TracChangeset
for help on using the changeset viewer.