Changeset 235
- Timestamp:
- 09/30/13 03:39:55 (11 years ago)
- Location:
- ksyslog/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ksyslog/trunk/ksyslog.c
r234 r235 128 128 { 129 129 struct ksyslog_entry *entry; 130 unsigned int facility, severity; 131 unsigned char priority, *start; 130 unsigned int priority, facility, severity, month, day, hour, minute, second; 131 unsigned char *start, month_s[4]; 132 struct tm tm; 132 133 int length, i; 133 134 134 if (sscanf(skb->data, "<%3hhu>", &priority) != 1) 135 if (sscanf(skb->data, "<%3u>%3s %2u %2u:%2u:%2u ", 136 &priority, month_s, &day, &hour, &minute, &second) != 6) 135 137 return ERR_PTR(-EINVAL); 136 138 … … 146 148 return ERR_PTR(-EINVAL); 147 149 if (severity >= __KSYSLOG_S_MAX) 150 return ERR_PTR(-EINVAL); 151 152 month = ksyslog_month_num(month_s); 153 if (!month) 154 return ERR_PTR(-EINVAL); 155 if (day > 31) 156 return ERR_PTR(-EINVAL); 157 if (hour > 23) 158 return ERR_PTR(-EINVAL); 159 if (minute > 59) 160 return ERR_PTR(-EINVAL); 161 if (second > 59) 148 162 return ERR_PTR(-EINVAL); 149 163 … … 164 178 do_gettimeofday(&entry->tv); 165 179 180 time_to_tm(entry->tv.tv_sec, 0, &tm); 181 entry->time = mktime(tm.tm_year + 1900, month, day, hour, minute, second); 182 183 entry->priority = priority; 166 184 entry->facility = facility; 167 185 entry->severity = severity; -
ksyslog/trunk/ksyslog.h
r232 r235 52 52 struct ksyslog_entry { 53 53 struct list_head list; 54 struct timeval tv; 54 55 55 struct timeval tv; 56 unsigned long time; 57 unsigned int priority; 56 58 enum ksyslog_facility facility; 57 59 enum ksyslog_severity severity; … … 123 125 } 124 126 127 static inline __u8 128 ksyslog_month_num(const char *month) 129 { 130 if (!memcmp(month, "Jan", 3)) 131 return 1; 132 else if (!memcmp(month, "Feb", 3)) 133 return 2; 134 else if (!memcmp(month, "Mar", 3)) 135 return 3; 136 else if (!memcmp(month, "Apr", 3)) 137 return 4; 138 else if (!memcmp(month, "May", 3)) 139 return 5; 140 else if (!memcmp(month, "Jun", 3)) 141 return 6; 142 else if (!memcmp(month, "Jul", 3)) 143 return 7; 144 else if (!memcmp(month, "Aug", 3)) 145 return 8; 146 else if (!memcmp(month, "Sep", 3)) 147 return 9; 148 else if (!memcmp(month, "Oct", 3)) 149 return 10; 150 else if (!memcmp(month, "Nov", 3)) 151 return 11; 152 else if (!memcmp(month, "Dec", 3)) 153 return 12; 154 else 155 return 0; 156 } 157 125 158 #endif
Note: See TracChangeset
for help on using the changeset viewer.