{"thread":{"id":"50144","subject":"[PATCH] banned.h: mark strncat() as banned","startedAt":"2019-01-02T09:38:48Z","lastAt":"2019-01-03T04:49:45Z","messageCount":3,"participants":["Eric Wong","Eric Sunshine","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"366031","messageId":"20190102093846.6664-1-e@80x24.org","threadId":"50144","inReplyTo":null,"subject":"[PATCH] banned.h: mark strncat() as banned","fromName":"Eric Wong","fromEmail":"e@80x24.org","sentAt":"2019-01-02T09:38:46Z","receivedAt":"2019-01-02T09:38:48Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"strncat() has the same quadratic behavior as strcat() and is\ndifficult-to-read and bug-prone.  While it hasn't yet been a\nproblem in git iself, strncat() found it's way into 'master'\nof cgit and caused segfaults on my system.\n\nSigned-off-by: Eric Wong <e@80x24.org>\n---\n banned.h | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/banned.h b/banned.h\nindex 28f5937035..447af24807 100644\n--- a/banned.h\n+++ b/banned.h\n@@ -16,6 +16,8 @@\n #define strcat(x,y) BANNED(strcat)\n #undef strncpy\n #define strncpy(x,y,n) BANNED(strncpy)\n+#undef strncat\n+#define strncat(x,y,n) BANNED(strncat)\n \n #undef sprintf\n #undef vsprintf\n-- \nEW\n\n"},{"id":"366046","messageId":"CAPig+cR2w3S==3-zstjmuB9jw4H-aPK7xqMeMLK-P94=+18jJQ@mail.gmail.com","threadId":"50144","inReplyTo":"20190102093846.6664-1-e@80x24.org","subject":"Re: [PATCH] banned.h: mark strncat() as banned","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-01-02T18:00:14Z","receivedAt":"2019-01-02T18:00:26Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Jan 2, 2019 at 4:38 AM Eric Wong <e@80x24.org> wrote:\n>\n> strncat() has the same quadratic behavior as strcat() and is\n> difficult-to-read and bug-prone.  While it hasn't yet been a\n> problem in git iself, strncat() found it's way into 'master'\n\ns/iself/itself/\n\n> of cgit and caused segfaults on my system.\n>\n> Signed-off-by: Eric Wong <e@80x24.org>\n"},{"id":"366062","messageId":"20190103044941.GA20047@sigill.intra.peff.net","threadId":"50144","inReplyTo":"20190102093846.6664-1-e@80x24.org","subject":"Re: [PATCH] banned.h: mark strncat() as banned","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-01-03T04:49:41Z","receivedAt":"2019-01-03T04:49:45Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jan 02, 2019 at 09:38:46AM +0000, Eric Wong wrote:\n\n> strncat() has the same quadratic behavior as strcat() and is\n> difficult-to-read and bug-prone.  While it hasn't yet been a\n> problem in git iself, strncat() found it's way into 'master'\n> of cgit and caused segfaults on my system.\n\nI'm in favor of this.\n\nIt doesn't have the \"oops, I didn't NUL-terminate for you\" problem that\nstrncpy() has. But it actually has the opposite problem! It will always\nplace a NUL, and you have to feed it sizeof(dst)-1 to avoid an overflow.\n\nSo I think it's important for safety (though I'd be fine banning it on\nthe quadratic grounds alone ;) ).\n\n-Peff\n"}]}