BUG/MEDIUM: mux-h2: Don't fail if nothing is parsed for a legacy chunk response

The parsing of incomplete chunk formatting in legacy HTTP mode was fixed by the
commit 6ad7cd981 ("BUG/MEDIUM: mux-h2: Emit an error if the response chunk
formatting is incomplete"). But a bug was introduced. When nothing is parsed, an
error is also returned. It may happens if the parsing is stopped just after a
chunk CRLF. When we try to parse the following chunk size, if there is no more
data to parse, an protocol error is returned. It is obviously wrong.

The patch was directly introduced on 2.0, there is no upstream commit ID for
this patch.

This patch is related to issue #798 and reported in comment in issue #768. It
must be backported to 1.8.
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 9e2746d..abe78d3 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -4324,9 +4324,15 @@
 		if (h1m->state == H1_MSG_CHUNK_CRLF) {
 			ret = h1_skip_chunk_crlf(buf, ofs, ofs + max);
 			if (ret <= 0) {
-				/* FIXME: bad contents or truncated response. how to proceed here when we're in H2 ? */
-				h1m->err_pos = ofs + max + ret;
-				h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
+				/* FIXME: bad contents or truncated response. how to proceed here when we're in H2 ?
+				 *        It should not happen except if opposite connection was closed.
+				 * Note: check there is at least something to parse to be sure the chunk crlf
+				 *       is truncated.
+				 */
+				if (max) {
+					h1m->err_pos = ofs + max + ret;
+					h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
+				}
 				goto end;
 			}
 			max -= ret;
@@ -4339,9 +4345,15 @@
 			unsigned int chunk;
 			ret = h1_parse_chunk_size(buf, ofs, ofs + max, &chunk);
 			if (ret <= 0) {
-				/* FIXME: bad contents or truncated response. how to proceed here when we're in H2 ? */
-				h1m->err_pos = ofs + max + ret;
-				h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
+				/* FIXME: bad contents or truncated response. how to proceed here when we're in H2 ?
+				 *        It should not happen except if opposite connection was closed.
+				 * Note: check there is at least something to parse to be sure the chunke size
+				 *       is truncated.
+				 */
+				if (max) {
+					h1m->err_pos = ofs + max + ret;
+					h2s_error(h2s, H2_ERR_INTERNAL_ERROR);
+				}
 				goto end;
 			}