commit 113392cfbd4d2583badd52487063cd5f84f55518 from: Stefan Sperling via: Thomas Adam date: Mon Jan 23 18:21:06 2023 UTC make read errors in gotsh serve_read() fatal and adjust tests accordingly ok jamsek commit - 23ac500059fe541c262531df0c2877bd1f547887 commit + 113392cfbd4d2583badd52487063cd5f84f55518 blob - 515a0296929c24485c2fb911b0240a3feb445be5 blob + 7ea752a579b9088f87864838136a57c678490630 --- lib/serve.c +++ lib/serve.c @@ -896,7 +896,7 @@ serve_read(int infd, int outfd, int gotd_sock, const c buf[0] = '\0'; err = got_pkt_readpkt(&n, infd, buf, sizeof(buf), chattygot); if (err) - break; + goto done; if (n == 0) { if (curstate != STATE_EXPECT_WANT && curstate != STATE_EXPECT_MORE_WANT && blob - a71399675b8b4529b335bd950c4d69784afeaeb9 blob + de03ac23d77bc68db8468d312559b0ddd55d651c --- regress/cmdline/common.sh +++ regress/cmdline/common.sh @@ -24,6 +24,7 @@ export GOT_AUTHOR_11="flan_hacker" export GOT_LOG_DEFAULT_LIMIT=0 export GOT_TEST_ROOT="/tmp" export GOT_IGNORE_GITCONFIG=1 +export GOT_VERSION_STR=`got --version | cut -d ' ' -f2` export MALLOC_OPTIONS=S blob - 2896db4ceb362abfd70987b33dcf5f158b418c91 blob + 113aa4cf7bd50234a0d5ea376652934c0ef7b007 --- regress/gotd/request_bad.sh +++ regress/gotd/request_bad.sh @@ -93,12 +93,16 @@ test_request_bad_length_empty() { | ssh ${GOTD_DEVUSER}@127.0.0.1 git-upload-pack '/test-repo' \ > $testroot/stdout 2>$testroot/stderr - printf "00000008NAK\n0021ERR read: Bad file descriptor" \ + echo -n '006c0000000000000000000000000000000000000000 ' \ > $testroot/stdout.expected + printf "capabilities^{}\0" >> $testroot/stdout.expected + echo -n " agent=got/${GOT_VERSION_STR} ofs-delta side-band-64k" \ + >> $testroot/stdout.expected + echo -n '00000018ERR packet too short' >> $testroot/stdout.expected - echo "gotsh: read: Bad file descriptor" > $testroot/stderr.expected + echo "gotsh: packet too short" > $testroot/stderr.expected - cmp -s $testroot/stdout.expected $testroot/stdout 0 108 + cmp -s $testroot/stdout.expected $testroot/stdout ret=$? if [ $ret -ne 0 ]; then echo "unexpected stdout" >&2 @@ -125,12 +129,16 @@ test_request_bad_length_small() { | ssh ${GOTD_DEVUSER}@127.0.0.1 git-upload-pack '/test-repo' \ > $testroot/stdout 2>$testroot/stderr - printf "00000008NAK\n0021ERR read: Bad file descriptor" \ + echo -n '006c0000000000000000000000000000000000000000 ' \ > $testroot/stdout.expected + printf "capabilities^{}\0" >> $testroot/stdout.expected + echo -n " agent=got/${GOT_VERSION_STR} ofs-delta side-band-64k" \ + >> $testroot/stdout.expected + echo -n '00000018ERR packet too short' >> $testroot/stdout.expected - echo "gotsh: read: Bad file descriptor" > $testroot/stderr.expected + echo "gotsh: packet too short" > $testroot/stderr.expected - cmp -s $testroot/stdout.expected $testroot/stdout 0 108 + cmp -s $testroot/stdout.expected $testroot/stdout ret=$? if [ $ret -ne 0 ]; then echo "unexpected stdout" >&2 @@ -157,12 +165,17 @@ test_request_bad_length_large() { | ssh ${GOTD_DEVUSER}@127.0.0.1 git-upload-pack '/test-repo' \ > $testroot/stdout 2>$testroot/stderr - printf "00000008NAK\n0021ERR read: Bad file descriptor" \ + echo -n '006c0000000000000000000000000000000000000000 ' \ > $testroot/stdout.expected + printf "capabilities^{}\0" >> $testroot/stdout.expected + echo -n " agent=got/${GOT_VERSION_STR} ofs-delta side-band-64k" \ + >> $testroot/stdout.expected + echo -n '0000001eERR unexpected end of file' \ + >> $testroot/stdout.expected - echo "gotsh: read: Bad file descriptor" > $testroot/stderr.expected + echo "gotsh: unexpected end of file" > $testroot/stderr.expected - cmp -s $testroot/stdout.expected $testroot/stdout 0 108 + cmp -s $testroot/stdout.expected $testroot/stdout ret=$? if [ $ret -ne 0 ]; then echo "unexpected stdout" >&2