Skip to content

Instantly share code, notes, and snippets.

@weltling
Created April 28, 2014 14:57
Show Gist options
  • Save weltling/11374615 to your computer and use it in GitHub Desktop.
Save weltling/11374615 to your computer and use it in GitHub Desktop.
--- ext/fileinfo/libmagic.orig/readcdf.c Tue Jan 7 04:13:42 2014
+++ readcdf_new.c Mon Apr 28 16:55:57 2014
@@ -97,6 +97,8 @@
const char *s;
int len;
+ memset(&ts, 0, sizeof(ts));
+
for (i = 0; i < count; i++) {
cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);
switch (info[i].pi_type) {
@@ -171,8 +173,11 @@
return -1;
} else {
char *c, *ec;
- cdf_timestamp_to_timespec(&ts, tp);
- c = cdf_ctime(&ts.tv_sec, tbuf);
+ const time_t sec = ts.tv_sec;
+ if (cdf_timestamp_to_timespec(&ts, tp) == -1) {
+ return -1;
+ }
+ c = cdf_ctime(&sec, tbuf);
if (c != NULL &&
(ec = strchr(c, '\n')) != NULL)
*ec = '\0';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment