From f920de10f796ecdd39f8907c49615ffe7208a3de Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 5 Oct 2020 15:09:13 -0700 Subject: [PATCH] peek_packet.c: always use at least 4K buffer Instead of just using a PATH_MAX size buffer, use a min(PATH_MAX,4096) size buffer. Signed-off-by: Kyle J. McKay --- src/peek_packet.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/peek_packet.c b/src/peek_packet.c index 1e43142..7f3dd73 100644 --- a/src/peek_packet.c +++ b/src/peek_packet.c @@ -1,7 +1,7 @@ /* peek_packet.c -- peek_packet utility to peek at incoming git-daemon request -Copyright (C) 2015 Kyle J. McKay. All rights reserved. +Copyright (C) 2015,2020 Kyle J. McKay. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -80,6 +80,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define POLL_QUANTUM 100000U /* how often to poll in microseconds */ +#if !defined(PATH_MAX) || PATH_MAX+0 < 4096 +#define BUFF_MAX 4096 +#else +#define BUFF_MAX PATH_MAX +#endif + static int xdig(char c) { if ('0' <= c && c <= '9') @@ -91,7 +97,7 @@ static int xdig(char c) return -1; } -static char buffer[PATH_MAX]; +static char buffer[BUFF_MAX]; static time_t expiry; /* Ideally we could just use MSG_PEEK + MSG_WAITALL, and that works nicely -- 2.11.4.GIT