{"thread":{"id":"7779","subject":"[PATCH] Fix a typo in crlf conversion code","startedAt":"2007-04-22T14:12:22Z","lastAt":"2007-04-22T22:52:47Z","messageCount":2,"participants":["Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"40118","messageId":"20070422141222.GC2431@steel.home","threadId":"7779","inReplyTo":null,"subject":"[PATCH] Fix a typo in crlf conversion code","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-04-22T14:12:22Z","receivedAt":"2007-04-22T14:12:22Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Also, noticed by valgrind: the code caused a read out-of-bounds.\nSome comments updated as well (they still reflected old calling\nconventions).\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n convert.c |   10 +++++-----\n 1 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/convert.c b/convert.c\nindex 37239ac..ad106ef 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -115,8 +115,8 @@ static char *crlf_to_git(const char *path, const char *src, unsigned long *sizep\n \t}\n \n \t/*\n-\t * Ok, allocate a new buffer, fill it in, and return true\n-\t * to let the caller know that we switched buffers on it.\n+\t * Ok, allocate a new buffer, fill it in, and return it\n+\t * to let the caller know that we switched buffers.\n \t */\n \tnsize = size - stats.crlf;\n \tbuffer = xmalloc(nsize);\n@@ -137,7 +137,7 @@ static char *crlf_to_git(const char *path, const char *src, unsigned long *sizep\n \t} else {\n \t\tdo {\n \t\t\tunsigned char c = *src++;\n-\t\t\tif (! (c == '\\r' && (1 < size && *buffer == '\\n')))\n+\t\t\tif (! (c == '\\r' && (1 < size && *src == '\\n')))\n \t\t\t\t*dst++ = c;\n \t\t} while (--size);\n \t}\n@@ -180,8 +180,8 @@ static char *crlf_to_worktree(const char *path, const char *src, unsigned long *\n \t}\n \n \t/*\n-\t * Ok, allocate a new buffer, fill it in, and return true\n-\t * to let the caller know that we switched buffers on it.\n+\t * Ok, allocate a new buffer, fill it in, and return it\n+\t * to let the caller know that we switched buffers.\n \t */\n \tnsize = size + stats.lf - stats.crlf;\n \tbuffer = xmalloc(nsize);\n-- \n1.5.1.1.946.gdb75a\n"},{"id":"40162","messageId":"20070422225247.GA2409@steel.home","threadId":"7779","inReplyTo":"20070422141222.GC2431@steel.home","subject":"Re: [PATCH] Fix crash in t0020 (crlf conversion)","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-04-22T22:52:47Z","receivedAt":"2007-04-22T22:52:47Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Alex Riesen, Sun, Apr 22, 2007 16:11:54 +0200:\n> Reallocated wrong size.\n> Noticed on Ubuntu 7.04 probably because it has some malloc diagnostics in libc:\n> \"git-read-tree --reset -u HEAD\" aborted in the test. Valgrind sped up the\n> debugging greatly: took me 10 minutes.\n\nAlex Riesen, Sun, Apr 22, 2007 16:12:22 +0200:\n> Also, noticed by valgrind: the code caused a read out-of-bounds.\n> Some comments updated as well (they still reflected old calling\n> conventions).\n\nActually, it is all the other way around. The _second_ patch\n(buffer->src in convert.c, the read out-of-bounds caused overwrite of\nmalloc control structures because of incorrect dst update condition)\nis for the crash, the first is unrelated, but noticed by valgrind\nin the same test.\n\nI messed up the commit descriptions completely (Martins mail made\nme look at the patches again). Sorry\n"}]}