git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Crashes while trying to show tag objects with bad timestamps
@ 2013-02-22 22:30 Mantas Mikulėnas
  2013-02-22 22:46 ` Jeff King
  2013-02-22 23:01 ` [RFC/PATCH] hash-object doc: "git hash-object -w" can write invalid objects Jonathan Nieder
  0 siblings, 2 replies; 16+ messages in thread
From: Mantas Mikulėnas @ 2013-02-22 22:30 UTC (permalink / raw)
  To: git

When messing around with various repositories, I noticed that git 1.8
(currently using 1.8.2.rc0.22.gb3600c3) has problems parsing tag objects
that have invalid timestamps.

Times in tag objects appear to be kept as Unix timestamps, but I didn't
realize this at first, and ran something roughly equivalent to:
  git cat-file -p $tagname | git hash-object -w -t tag --stdin
creating a tag object the "tagger" line containing formatted time
instead of a Unix timestamp.

Git doesn't handle the resulting tag objects nicely at all. For example,
running `git cat-file -p` on the new object outputs a really odd
timestamp "Thu Jun Thu Jan 1 00:16:09 1970 +0016" (I'm guessing it
parses the year as Unix time), and `git show` outright crashes
(backtrace included below.)

I would have expected both commands to print a "tag object corrupt"
message, or maybe even a more specific "bad timestamp in tagger line"...

To reproduce:

printf '%s\n' \
  'object 4b825dc642cb6eb9a060e54bf8d69288fbee4904' 'type tree' \
  'tag test' 'tagger User <user@none> Thu Jun 9 16:44:04 2005 +0000' \
  '' 'Test tag' | git hash-object -w -t tag --stdin | xargs git show


> #0  0x00007f42560bb5f3 in ____strtoull_l_internal () from /usr/lib/libc.so.6
> No symbol table info available.
> #1  0x00000000004b4c81 in pp_user_info (pp=pp@entry=0x7fff3c30f1a0, 
>     what=what@entry=0x50c13b "Tagger", sb=sb@entry=0x7fff3c30f140, 
>     line=0xc267c7 "Jilles Tjoelker <jilles@stack.nl> Thu Jun 9 16:44:04 2005 +0000\n\nTag 1.0rc1.\n\n", encoding=0x507e20 "UTF-8") at pretty.c:431
>         name = {alloc = 24, len = 15, buf = 0xc24690 "Jilles Tjoelker"}
>         mail = {alloc = 24, len = 15, buf = 0xc24750 "jilles@stack.nl"}
>         ident = {
>           name_begin = 0xc267c7 "Jilles Tjoelker <jilles@stack.nl> Thu Jun 9 16:44:04 2005 +0000\n\nTag 1.0rc1.\n\n", 
>           name_end = 0xc267d6 " <jilles@stack.nl> Thu Jun 9 16:44:04 2005 +0000\n\nTag 1.0rc1.\n\n", 
>           mail_begin = 0xc267d8 "jilles@stack.nl> Thu Jun 9 16:44:04 2005 +0000\n\nTag 1.0rc1.\n\n", mail_end = 0xc267e7 "> Thu Jun 9 16:44:04 2005 +0000\n\nTag 1.0rc1.\n\n", 
>           date_begin = 0x0, date_end = 0x0, tz_begin = 0x0, tz_end = 0x0}
>         linelen = <optimized out>
>         line_end = <optimized out>
>         date = <optimized out>
>         mailbuf = 0xc267d8 "jilles@stack.nl> Thu Jun 9 16:44:04 2005 +0000\n\nTag 1.0rc1.\n\n"
>         namebuf = 0xc267c7 "Jilles Tjoelker <jilles@stack.nl> Thu Jun 9 16:44:04 2005 +0000\n\nTag 1.0rc1.\n\n"
>         namelen = 33
>         maillen = 15
>         max_length = 78
>         time = <optimized out>
>         tz = <optimized out>
> #2  0x0000000000439af5 in show_tagger (buf=<optimized out>, len=<optimized out>, 
>     rev=<optimized out>) at builtin/log.c:400
>         pp = {fmt = CMIT_FMT_MEDIUM, abbrev = 0, subject = 0x0, after_subject = 0x0, 
>           preserve_subject = 0, date_mode = DATE_NORMAL, date_mode_explicit = 0, 
>           need_8bit_cte = 0, notes_message = 0x0, reflog_info = 0x0, 
>           output_encoding = 0x0, mailmap = 0x0, color = 0}
>         out = {alloc = 0, len = 0, buf = 0x7a8188 <strbuf_slopbuf> ""}
> #3  show_tag_object (rev=0x7fff3c30f1f0, 
>     sha1=0xc2be44 "\230\211\275\331\365Q\306z\017\071d\331\035\062\247a\347~M8P", <incomplete sequence \303>) at builtin/log.c:427
>         new_offset = 151
>         type = OBJ_TAG
>         buf = 0xc26770 "object ffa28d13e40e03bd367d0219c7eb516be0f180d2\ntype commit\ntag hyperion-1.0rc1\ntagger Jilles Tjoelker <jilles@stack.nl> Thu Jun 9 16:44:04 2005 +0000\n\nTag 1.0rc1.\n\n"
>         size = 165
>         offset = <optimized out>


-- 
Mantas Mikulėnas <grawity@gmail.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2013-02-25 19:34 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-22 22:30 Crashes while trying to show tag objects with bad timestamps Mantas Mikulėnas
2013-02-22 22:46 ` Jeff King
2013-02-22 22:53   ` Junio C Hamano
2013-02-22 23:04     ` Jeff King
2013-02-22 23:14       ` Mantas Mikulėnas
2013-02-25 18:21         ` Jeff King
2013-02-22 23:20       ` Junio C Hamano
2013-02-25 18:30         ` Jeff King
2013-02-25 18:38           ` [PATCH 1/4] handle malformed dates in ident lines Jeff King
2013-02-25 18:39           ` [PATCH/RFC 2/4] skip_prefix: return a non-const pointer Jeff King
2013-02-25 18:46           ` [PATCH 3/4] fsck: check "tagger" lines Jeff King
2013-02-25 18:50           ` [PATCH 4/4] cat-file: print tags raw for "cat-file -p" Jeff King
2013-02-25 19:33             ` Mantas Mikulėnas
2013-02-22 23:01 ` [RFC/PATCH] hash-object doc: "git hash-object -w" can write invalid objects Jonathan Nieder
2013-02-22 23:07   ` Junio C Hamano
2013-02-22 23:09   ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).