diff --git a/binr/rax2/rax2.c b/binr/rax2/rax2.c index e181fa2806..50a7042344 100644 --- a/binr/rax2/rax2.c +++ b/binr/rax2/rax2.c @@ -259,9 +259,8 @@ static int rax (char *str, int len, int last) { } else if (flags & 2048) { // -t ut32 n = r_num_math (num, str); RPrint *p = r_print_new (); - p->big_endian = 0; // TODO: honor endian here - r_mem_copyendian ((ut8*) &n, (ut8*) &n, 8, 0); // fix endian here - r_print_date_unix (p, (const ut8*)&n, sizeof (ut64)); + r_mem_copyendian ((ut8*) &n, (ut8*) &n, 4, !(flags & 2)); + r_print_date_unix (p, (const ut8*)&n, sizeof (ut32)); r_print_free (p); return R_TRUE; } else if (flags & 4096) { // -E diff --git a/libr/core/cmd_print.c b/libr/core/cmd_print.c index f407230614..fefbaad7bf 100644 --- a/libr/core/cmd_print.c +++ b/libr/core/cmd_print.c @@ -2782,12 +2782,12 @@ static int cmd_print(void *data, const char *input) { switch (input[1]) { case ' ': case '\0': - for (l=0; lprint, core->block+l, sizeof (time_t)); + for (l=0; lprint, core->block+l, sizeof (ut32)); break; case 'd': - for (l=0; lprint, core->block+l, 4); + for (l=0; lprint, core->block+l, sizeof (ut32)); break; case 'n': core->print->big_endian = !core->print->big_endian; @@ -2798,9 +2798,9 @@ static int cmd_print(void *data, const char *input) { case '?':{ const char* help_msg[] = { "Usage: pt", "[dn]", "print timestamps", - "pt", "", "print unix time (32 bit `cfg.big_endian`", - "ptd","", "print dos time (32 bit `cfg.big_endian`", - "ptn","", "print ntfs time (64 bit `cfg.big_endian`", + "pt", "", "print unix time (32 bit `cfg.bigendian`)", + "ptd","", "print dos time (32 bit `cfg.bigendian`)", + "ptn","", "print ntfs time (64 bit `cfg.bigendian`)", NULL}; r_core_cmd_help (core, help_msg); } diff --git a/libr/util/p_date.c b/libr/util/p_date.c index d3d2d9429a..4d3224793c 100644 --- a/libr/util/p_date.c +++ b/libr/util/p_date.c @@ -31,13 +31,13 @@ R_API int r_print_date_dos(RPrint *p, ut8 *buf, int len) { } R_API int r_print_date_unix(RPrint *p, const ut8 *buf, int len) { - time_t t; + time_t t = 0; char s[256]; int ret = 0; const struct tm* time; - if (p != NULL && len >= sizeof(t)) { - r_mem_copyendian ((ut8*)&t, buf, sizeof(time_t), p->big_endian); + if (p != NULL && len >= sizeof(ut32)) { + r_mem_copyendian ((ut8*)&t, buf, sizeof(ut32), !p->big_endian); // "%d:%m:%Y %H:%M:%S %z", if (p->datefmt[0]) { t += p->datezone * (60*60); @@ -93,7 +93,7 @@ R_API int r_print_date_w32(RPrint *p, const ut8 *buf, int len) { char datestr[256]; if (p && len >= sizeof (ut64)) { - r_mem_copyendian ((ut8*)&l, buf, sizeof (ut64), p->big_endian); + r_mem_copyendian ((ut8*)&l, buf, sizeof (ut64), !p->big_endian); l /= 10000000; // 100ns to s l = (l > L ? l-L : 0); // isValidUnixTime? t = (time_t) l; // TODO limit above!