Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Redirect with an empty body causes infinite hang #7070

Open
@ehuss

Description

@ehuss

libgit2 seems to hang when cloning a URL that has a redirect with an empty body.

Reproduction steps

Try to clone the URL https://gitlab.com/ehuss/test

Expected behavior

Should be able to clone with a redirect.

Actual behavior

libgit2 hangs when cloning that URL. From my investigation, this is roughly what I see:

  1. gitlab responds to the initial request with a redirect to https://gitlab.com/ehuss/test.git/info/refs?service=git-upload-pack
    • Notice that it added .git to the URL
    • That response has a Content-Type: text/html; charset=utf-8 header and Content-Length: 0
  2. on_headers_complete detects the Content-Type header and sets client->state to READING_BODY
  3. The loop in http_stream_read goes again, generating a new request with the new URL
  4. git_http_client_send_request is called, and at the very top it detects READING_BODY and calls complete_response_body which tries to read more data from the server, but this hangs indefinitely since there is no body coming.

I'm not familiar enough with this code to make a real suggestion (maybe it should check for content_length==0 somewhere? or maybe it shouldn't set READING_BODY if content_length==0?).

Version of libgit2 (release number or SHA1)

21a351b

Operating system(s) tested

Any

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions