From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Lance Taylor To: kingdon@redhat.com Cc: tromey@cygnus.com, overseers@sourceware.cygnus.com Subject: Re: question about kcvs Date: Sat, 30 Dec 2000 06:08:00 -0000 Message-id: <20000520213013.15359.qmail@daffy.airs.com> References: <877lcqjiw6.fsf@cygnus.com> <20000520031018.9626.qmail@daffy.airs.com> <200005201723.NAA04789@devserv.devel.redhat.com> X-SW-Source: 2000/msg00559.html Date: Sat, 20 May 2000 13:23:05 -0400 From: Jim Kingdon So, Ian, care to submit a patch to CVS to fix the error reporting bug in CVS? I'll even check it in if you don't want to (although if memory serves you still do have checkin access to CVS). That is just embarrassing... "Use GDB to see the real error message"... Kind of cool in a geek way, but.... Geeze, I can't believe people are just too lazy to drop into gdb. What is the world coming to? I don't know if I still have cvs checkin access. I'm too lazy to find out. Ian 2000-05-20 Ian Lance Taylor * client.c (connect_to_gserver): Handle server error messages reasonably. --- client.c.~1~ Fri Aug 14 14:04:09 1998 +++ client.c Sat May 20 14:27:32 2000 @@ -3927,7 +3927,29 @@ recv_bytes (sock, cbuf, 2); need = ((cbuf[0] & 0xff) << 8) | (cbuf[1] & 0xff); - assert (need <= sizeof buf); + + if (need > sizeof buf) + { + int got; + + /* This usually means that the server sent us an error + message. Read it byte by byte and print it out. + FIXME: This is a terrible error handling strategy. + However, even if we fix the server, we will still + want to do this to work with older servers. */ + buf[0] = cbuf[0]; + buf[1] = cbuf[1]; + got = recv (sock, buf + 2, sizeof buf - 2, 0); + if (got < 0) + error (1, 0, "recv() from server %s: %s", + CVSroot_hostname, SOCK_STRERROR (SOCK_ERRNO)); + buf[got + 2] = '\0'; + if (buf[got + 1] == '\n') + buf[got + 1] = '\0'; + error (1, 0, "error from server %s: %s", CVSroot_hostname, + buf); + } + recv_bytes (sock, buf, need); tok_in.length = need; } From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Lance Taylor To: kingdon@redhat.com Cc: tromey@cygnus.com, overseers@sourceware.cygnus.com Subject: Re: question about kcvs Date: Sat, 20 May 2000 14:30:00 -0000 Message-ID: <20000520213013.15359.qmail@daffy.airs.com> References: <877lcqjiw6.fsf@cygnus.com> <20000520031018.9626.qmail@daffy.airs.com> <200005201723.NAA04789@devserv.devel.redhat.com> X-SW-Source: 2000-q2/msg00252.html Message-ID: <20000520143000.EjI7mCul875JYiTDpnlYY71gnuTKfg81dohDYslFjqM@z> Date: Sat, 20 May 2000 13:23:05 -0400 From: Jim Kingdon So, Ian, care to submit a patch to CVS to fix the error reporting bug in CVS? I'll even check it in if you don't want to (although if memory serves you still do have checkin access to CVS). That is just embarrassing... "Use GDB to see the real error message"... Kind of cool in a geek way, but.... Geeze, I can't believe people are just too lazy to drop into gdb. What is the world coming to? I don't know if I still have cvs checkin access. I'm too lazy to find out. Ian 2000-05-20 Ian Lance Taylor * client.c (connect_to_gserver): Handle server error messages reasonably. --- client.c.~1~ Fri Aug 14 14:04:09 1998 +++ client.c Sat May 20 14:27:32 2000 @@ -3927,7 +3927,29 @@ recv_bytes (sock, cbuf, 2); need = ((cbuf[0] & 0xff) << 8) | (cbuf[1] & 0xff); - assert (need <= sizeof buf); + + if (need > sizeof buf) + { + int got; + + /* This usually means that the server sent us an error + message. Read it byte by byte and print it out. + FIXME: This is a terrible error handling strategy. + However, even if we fix the server, we will still + want to do this to work with older servers. */ + buf[0] = cbuf[0]; + buf[1] = cbuf[1]; + got = recv (sock, buf + 2, sizeof buf - 2, 0); + if (got < 0) + error (1, 0, "recv() from server %s: %s", + CVSroot_hostname, SOCK_STRERROR (SOCK_ERRNO)); + buf[got + 2] = '\0'; + if (buf[got + 1] == '\n') + buf[got + 1] = '\0'; + error (1, 0, "error from server %s: %s", CVSroot_hostname, + buf); + } + recv_bytes (sock, buf, need); tok_in.length = need; }