git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Thomas Rast <trast@student.ethz.ch>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: <git@vger.kernel.org>, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 2/2] Make hash-object more robust against malformed objects
Date: Sat, 12 Feb 2011 12:42:21 +0100	[thread overview]
Message-ID: <201102121242.21339.trast@student.ethz.ch> (raw)
In-Reply-To: <1296903141-27075-2-git-send-email-pclouds@gmail.com>

Nguyễn Thái Ngọc Duy wrote:
> Commits, trees and tags have structure. Don't let users feed git
> with malformed ones. Sooner or later git will die() when
> encountering them.
> 
> Note that this patch does not check semantics. A tree that points
> to non-existent objects is perfectly OK (and should be so, users
> may choose to add commit first, then its associated tree for example)
> 
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>

This patch makes t9350 fail under valgrind:

expecting success: 

        TAG=$(git hash-object -t tag -w tag-content) &&
        git update-ref refs/tags/sonnenschein $TAG &&
        git fast-export -C -C --signed-tags=strip --all > output &&
        test $(grep -c "^tag " output) = 4 &&
        ! grep "Unspecified Tagger" output &&
        git fast-export -C -C --signed-tags=strip --all \
                --fake-missing-tagger > output &&
        test $(grep -c "^tag " output) = 4 &&
        grep "Unspecified Tagger" output


==2862== Invalid read of size 1
==2862==    at 0x4F0C34: prefixcmp (strbuf.c:9)
==2862==    by 0x4F4FB3: parse_tag_buffer (tag.c:109)
==2862==    by 0x4EC686: check_tag (sha1_file.c:2499)
==2862==    by 0x4EC77F: index_mem (sha1_file.c:2529)
==2862==    by 0x4EC934: index_fd (sha1_file.c:2563)
==2862==    by 0x4379C9: hash_fd (hash-object.c:17)
==2862==    by 0x437A86: hash_object (hash-object.c:33)
==2862==    by 0x437E82: cmd_hash_object (hash-object.c:126)
==2862==    by 0x404771: run_builtin (git.c:290)
==2862==    by 0x4048FC: handle_internal_command (git.c:448)
==2862==    by 0x4049E7: run_argv (git.c:492)
==2862==    by 0x404B43: main (git.c:565)
==2862==  Address 0x55abb77 is 0 bytes after a block of size 71 alloc'd
==2862==    at 0x4C20E1C: malloc (vg_replace_malloc.c:195)
==2862==    by 0x504A7C: xmalloc (wrapper.c:35)
==2862==    by 0x4EC8E8: index_fd (sha1_file.c:2561)
==2862==    by 0x4379C9: hash_fd (hash-object.c:17)
==2862==    by 0x437A86: hash_object (hash-object.c:33)
==2862==    by 0x437E82: cmd_hash_object (hash-object.c:126)
==2862==    by 0x404771: run_builtin (git.c:290)
==2862==    by 0x4048FC: handle_internal_command (git.c:448)
==2862==    by 0x4049E7: run_argv (git.c:492)
==2862==    by 0x404B43: main (git.c:565)
==2862== 
==2862== Invalid read of size 1
==2862==    at 0x4F0C50: prefixcmp (strbuf.c:10)
==2862==    by 0x4F4FB3: parse_tag_buffer (tag.c:109)
==2862==    by 0x4EC686: check_tag (sha1_file.c:2499)
==2862==    by 0x4EC77F: index_mem (sha1_file.c:2529)
==2862==    by 0x4EC934: index_fd (sha1_file.c:2563)
==2862==    by 0x4379C9: hash_fd (hash-object.c:17)
==2862==    by 0x437A86: hash_object (hash-object.c:33)
==2862==    by 0x437E82: cmd_hash_object (hash-object.c:126)
==2862==    by 0x404771: run_builtin (git.c:290)
==2862==    by 0x4048FC: handle_internal_command (git.c:448)
==2862==    by 0x4049E7: run_argv (git.c:492)
==2862==    by 0x404B43: main (git.c:565)
==2862==  Address 0x55abb77 is 0 bytes after a block of size 71 alloc'd
==2862==    at 0x4C20E1C: malloc (vg_replace_malloc.c:195)
==2862==    by 0x504A7C: xmalloc (wrapper.c:35)
==2862==    by 0x4EC8E8: index_fd (sha1_file.c:2561)
==2862==    by 0x4379C9: hash_fd (hash-object.c:17)
==2862==    by 0x437A86: hash_object (hash-object.c:33)
==2862==    by 0x437E82: cmd_hash_object (hash-object.c:126)
==2862==    by 0x404771: run_builtin (git.c:290)
==2862==    by 0x4048FC: handle_internal_command (git.c:448)
==2862==    by 0x4049E7: run_argv (git.c:492)
==2862==    by 0x404B43: main (git.c:565)
==2862== 
not ok - 15 cope with tagger-less tags
#       
#       
#               TAG=$(git hash-object -t tag -w tag-content) &&
#               git update-ref refs/tags/sonnenschein $TAG &&
#               git fast-export -C -C --signed-tags=strip --all > output &&
#               test $(grep -c "^tag " output) = 4 &&
#               ! grep "Unspecified Tagger" output &&
#               git fast-export -C -C --signed-tags=strip --all \
#                       --fake-missing-tagger > output &&
#               test $(grep -c "^tag " output) = 4 &&
#               grep "Unspecified Tagger" output
#       
#       

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

  reply	other threads:[~2011-02-12 11:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-05 10:52 [PATCH 1/2] Add const to parse_{commit,tag}_buffer() Nguyễn Thái Ngọc Duy
2011-02-05 10:52 ` [PATCH 2/2] Make hash-object more robust against malformed objects Nguyễn Thái Ngọc Duy
2011-02-12 11:42   ` Thomas Rast [this message]
2011-02-12 14:47     ` Nguyen Thai Ngoc Duy
2011-02-14 13:02       ` [PATCH] parse_tag_buffer(): do not prefixcmp() out of range Nguyễn Thái Ngọc Duy
2011-02-15 21:18         ` Junio C Hamano
2011-02-16  3:39           ` Nguyen Thai Ngoc Duy
2011-02-17 12:43             ` René Scharfe
2011-02-18 12:49               ` [PATCH] parse_tag_buffer(): avoid out of bound access Nguyễn Thái Ngọc Duy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201102121242.21339.trast@student.ethz.ch \
    --to=trast@student.ethz.ch \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).