git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] Make hash-object more robust against malformed objects

From
Thomas Rast <trast@student.ethz.ch>
Date
Feb 12, 2011, 11:42 UTC
Message-ID
<201102121242.21339.trast@student.ethz.ch>
In-Reply-To
<1296903141-27075-2-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy wrote:
Show 9 quoted lines
> 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
Previous: Nguyễn Thái Ngọc DuyNext: Nguyen Thai Ngoc Duy
Message 3 of 9 in “Add const to parse_{commit,tag}_buffer()”
  1. 1/2 Add const to parse_{commit,tag}_buffer()Nguyễn Thái Ngọc Duy, Feb 5, 2011
  2. 2/2 Make hash-object more robust against malformed objectsNguyễn Thái Ngọc Duy, Feb 5, 2011
  3. Thomas RastFeb 12, 2011
  4. Nguyen Thai Ngoc DuyFeb 12, 2011
  5. parse_tag_buffer(): do not prefixcmp() out of rangeNguyễn Thái Ngọc Duy, Feb 14, 2011
  6. Junio C HamanoFeb 15, 2011
  7. Nguyen Thai Ngoc DuyFeb 16, 2011
  8. René ScharfeFeb 17, 2011
  9. parse_tag_buffer(): avoid out of bound accessNguyễn Thái Ngọc Duy, Feb 18, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.