diff options
author | Christos Zoulas <christos@zoulas.com> | 2021-06-30 10:08:48 +0000 |
---|---|---|
committer | Christos Zoulas <christos@zoulas.com> | 2021-06-30 10:08:48 +0000 |
commit | d484974acb1d292188e62e57df4da038b495c05e (patch) | |
tree | fd0a4cec28e8e09b0dfe0dfcf33f1b4470e9076f /src/print.c | |
parent | 2f183536a6275bcd521cced81b060ffed76c3a42 (diff) | |
download | file-git-d484974acb1d292188e62e57df4da038b495c05e.tar.gz |
PR/270: Don't translate unprintable characters in %s magic formats when -r
Diffstat (limited to 'src/print.c')
-rw-r--r-- | src/print.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/print.c b/src/print.c index 09f64811..6d9816ad 100644 --- a/src/print.c +++ b/src/print.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: print.c,v 1.88 2020/05/09 18:57:15 christos Exp $") +FILE_RCSID("@(#)$File: print.c,v 1.89 2021/06/30 10:08:48 christos Exp $") #endif /* lint */ #include <string.h> @@ -197,6 +197,11 @@ file_mdump(struct magic *m) case FILE_LEDOUBLE: (void) fprintf(stderr, "%G", m->value.d); break; + case FILE_LEVARINT: + case FILE_BEVARINT: + (void)fprintf(stderr, "%s", file_fmtvarint( + m->value.us, m->type, tbuf, sizeof(tbuf))); + break; case FILE_DEFAULT: /* XXX - do anything here? */ break; @@ -240,6 +245,13 @@ file_magwarn(struct magic_set *ms, const char *f, ...) } protected const char * +file_fmtvarint(const unsigned char *us, int t, char *buf, size_t blen) +{ + snprintf(buf, blen, "%jd", file_varint2uintmax_t(us, t, NULL)); + return buf; +} + +protected const char * file_fmttime(char *buf, size_t bsize, uint64_t v, int flags) { char *pp; |