From c4b06934ede0ad50b4d88c6d7cc0bf86bc9ebb39 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Wed, 9 Jan 2013 12:56:57 +0300 Subject: [PATCH] cvsclient.c: don't return trash buffer when 'E ' is returned from first 'cvs rlog' entries Found by valgrind: $ valgrind ./cvsps --fast-export --root $CVSROOT -p z/ --debuglvl 0xff Kernel cvsps: cvsclient: rlog: read E cvs rlog: Logging Kernel cvsps: cvs rlog: Logging Kernel ==27619== Conditional jump or move depends on uninitialised value(s) ==27619== at 0x50938F2: vfprintf (vfprintf.c:1642) ==27619== by 0x514361F: __vsnprintf_chk (vsnprintf_chk.c:63) ==27619== by 0x10B7D4: vdebug (stdio2.h:77) ==27619== by 0x10CFED: debug (debug.h:52) ==27619== by 0x11095B: load_from_cvs (cvsps.c:338) ==27619== by 0x10AA19: main (cvsps.c:197) ==27619== Uninitialised value was created by a stack allocation ==27619== at 0x11089F: load_from_cvs (cvsps.c:301) Signed-off-by: Sergei Trofimovich Signed-off-by: Eric S. Raymond --- cvsclient.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cvsclient.c b/cvsclient.c index 681434e..6004b52 100644 --- a/cvsclient.c +++ b/cvsclient.c @@ -877,6 +877,7 @@ char * cvs_rlog_fgets(char * buff, int buflen, CvsServerCtx * ctx) char lbuff[BUFSIZ]; int len; + reread: len = read_line(ctx, lbuff, BUFSIZ); debug(DEBUG_TCP, "cvsclient: rlog: read %s", lbuff); @@ -889,6 +890,7 @@ char * cvs_rlog_fgets(char * buff, int buflen, CvsServerCtx * ctx) else if (memcmp(lbuff, "E ", 2) == 0) { debug(DEBUG_TCP, "%s", lbuff + 2); + goto reread; } else if (strcmp(lbuff, "ok") == 0 || strncmp(lbuff, "error", 5) == 0) { -- 2.1.4