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

[PATCH v4 04/12] cache: clear whole hash buffer with oidclr

From
Patryk Obara <patryk.obara@gmail.com>
Date
Jan 28, 2018, 00:13 UTC
Message-ID
<ca4fac44f11c767c6042404ed9ed0c2e1b2f5369.1517097306.git.patryk.obara@gmail.com>
In-Reply-To
<cover.1517097306.git.patryk.obara@gmail.com>

As long as GIT_SHA1_RAWSZ is equal to GIT_MAX_RAWSZ there's no problem, but when new hashing algorithm will be in place this memset will clear only 20-byte prefix of hash buffer.

Alternatively, hashclr implementation could be adjusted, but this function is almost removed from codebase already. Separate implementation of oidclr prevents potential buffer overrun in case someone incorrectly used hashclr on object_id in future.

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
---
 cache.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cache.h b/cache.h
index 08f2b81e1b..d5d78d6a51 100644
--- a/cache.h
+++ b/cache.h
@@ -1029,7 +1029,7 @@ static inline void hashclr(unsigned char *hash)
 
 static inline void oidclr(struct object_id *oid)
 {
-	hashclr(oid->hash);
+	memset(oid->hash, 0, GIT_MAX_RAWSZ);
 }
 
 
-- 
2.14.3
Previous: Patryk ObaraNext: Patryk Obara
Message 68 of 75 in “Some fixes and bunch of object_id conversions”
  1. 00/11 Some fixes and bunch of object_id conversionsPatryk Obara, Jan 18, 2018
  2. 01/11 http-push: improve error logPatryk Obara, Jan 18, 2018
  3. 02/11 clang-format: adjust penalty for return type line breakPatryk Obara, Jan 18, 2018
  4. 04/11 dir: convert struct sha1_stat to use object_idPatryk Obara, Jan 18, 2018
  5. 06/11 cache: clear whole hash buffer with oidclrPatryk Obara, Jan 18, 2018
  6. 07/11 match-trees: convert splice_tree to object_idPatryk Obara, Jan 18, 2018
  7. 09/11 notes: convert combine_notes_* to object_idPatryk Obara, Jan 18, 2018
  8. 08/11 commit: convert commit_tree* to object_idPatryk Obara, Jan 18, 2018
  9. 11/11 sha1_file: convert write_sha1_file to object_idPatryk Obara, Jan 18, 2018
  10. brian m. carlsonJan 20, 2018
  11. Patryk ObaraJan 21, 2018
  12. 10/11 notes: convert write_notes_tree to object_idPatryk Obara, Jan 18, 2018
  13. 05/11 sha1_file: convert hash_sha1_file to object_idPatryk Obara, Jan 18, 2018
  14. 03/11 sha1_file: convert pretend_sha1_file to object_idPatryk Obara, Jan 18, 2018
  15. Jonathan TanJan 18, 2018
  16. brian m. carlsonJan 20, 2018
  17. Patryk ObaraJan 21, 2018
  18. 00/14 Some fixes and bunch of object_id conversionsPatryk Obara, Jan 22, 2018
  19. 02/14 clang-format: adjust penalty for return type line breakPatryk Obara, Jan 22, 2018
  20. 03/14 sha1_file: convert pretend_sha1_file to object_idPatryk Obara, Jan 22, 2018
  21. 07/14 match-trees: convert splice_tree to object_idPatryk Obara, Jan 22, 2018
  22. Duy NguyenJan 22, 2018
  23. Patryk ObaraJan 22, 2018
  24. Duy NguyenJan 23, 2018
  25. 09/14 notes: convert combine_notes_* to object_idPatryk Obara, Jan 22, 2018
  26. 10/14 notes: convert write_notes_tree to object_idPatryk Obara, Jan 22, 2018
  27. Duy NguyenJan 22, 2018
  28. 11/14 sha1_file: convert write_sha1_file to object_idPatryk Obara, Jan 22, 2018
  29. 14/14 sha1_file: rename hash_sha1_file_literallyPatryk Obara, Jan 22, 2018
  30. 12/14 sha1_file: convert force_object_loose to object_idPatryk Obara, Jan 22, 2018
  31. 13/14 sha1_file: convert write_loose_object to object_idPatryk Obara, Jan 22, 2018
  32. 04/14 dir: convert struct sha1_stat to use object_idPatryk Obara, Jan 22, 2018
  33. 05/14 sha1_file: convert hash_sha1_file to object_idPatryk Obara, Jan 22, 2018
  34. Duy NguyenJan 22, 2018
  35. Patryk ObaraJan 22, 2018
  36. Duy NguyenJan 22, 2018
  37. 08/14 commit: convert commit_tree* to object_idPatryk Obara, Jan 22, 2018
  38. 06/14 cache: clear whole hash buffer with oidclrPatryk Obara, Jan 22, 2018
  39. 01/14 http-push: improve error logPatryk Obara, Jan 22, 2018
  40. Duy NguyenJan 22, 2018
  41. Patryk ObaraJan 22, 2018
  42. 00/14 Some fixes and bunch of object_id conversionsPatryk Obara, Jan 24, 2018
  43. 02/14 clang-format: adjust penalty for return type line breakPatryk Obara, Jan 24, 2018
  44. 07/14 match-trees: convert splice_tree to object_idPatryk Obara, Jan 24, 2018
  45. 11/14 sha1_file: convert write_sha1_file to object_idPatryk Obara, Jan 24, 2018
  46. 10/14 notes: convert write_notes_tree to object_idPatryk Obara, Jan 24, 2018
  47. 08/14 commit: convert commit_tree* to object_idPatryk Obara, Jan 24, 2018
  48. 09/14 notes: convert combine_notes_* to object_idPatryk Obara, Jan 24, 2018
  49. 13/14 sha1_file: convert write_loose_object to object_idPatryk Obara, Jan 24, 2018
  50. brian m. carlsonJan 26, 2018
  51. 12/14 sha1_file: convert force_object_loose to object_idPatryk Obara, Jan 24, 2018
  52. 14/14 sha1_file: rename hash_sha1_file_literallyPatryk Obara, Jan 24, 2018
  53. 01/14 http-push: improve error logPatryk Obara, Jan 24, 2018
  54. 05/14 sha1_file: convert hash_sha1_file to object_idPatryk Obara, Jan 24, 2018
  55. 03/14 sha1_file: convert pretend_sha1_file to object_idPatryk Obara, Jan 24, 2018
  56. 04/14 dir: convert struct sha1_stat to use object_idPatryk Obara, Jan 24, 2018
  57. Junio C HamanoJan 24, 2018
  58. 06/14 cache: clear whole hash buffer with oidclrPatryk Obara, Jan 24, 2018
  59. Junio C HamanoJan 24, 2018
  60. Junio C HamanoJan 24, 2018
  61. Duy NguyenJan 25, 2018
  62. brian m. carlsonJan 27, 2018
  63. 00/12 A bunch of object_id conversionsPatryk Obara, Jan 28, 2018
  64. 01/12 sha1_file: convert pretend_sha1_file to object_idPatryk Obara, Jan 28, 2018
  65. 03/12 sha1_file: convert hash_sha1_file to object_idPatryk Obara, Jan 28, 2018
  66. 05/12 match-trees: convert splice_tree to object_idPatryk Obara, Jan 28, 2018
  67. 08/12 notes: convert write_notes_tree to object_idPatryk Obara, Jan 28, 2018
  68. 04/12 cache: clear whole hash buffer with oidclrPatryk Obara, Jan 28, 2018
  69. 09/12 sha1_file: convert write_sha1_file to object_idPatryk Obara, Jan 28, 2018
  70. 07/12 notes: convert combine_notes_* to object_idPatryk Obara, Jan 28, 2018
  71. 10/12 sha1_file: convert force_object_loose to object_idPatryk Obara, Jan 28, 2018
  72. 11/12 sha1_file: convert write_loose_object to object_idPatryk Obara, Jan 28, 2018
  73. 12/12 sha1_file: rename hash_sha1_file_literallyPatryk Obara, Jan 28, 2018
  74. 06/12 commit: convert commit_tree* to object_idPatryk Obara, Jan 28, 2018
  75. 02/12 dir: convert struct sha1_stat to use object_idPatryk Obara, Jan 28, 2018

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.