X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/8bdbcf67d5686ab823e466e6df7900aec8c21c1a..3174e150a3c97a471998cfe73a11bd4996da9ab7:/methods/http.cc diff --git a/methods/http.cc b/methods/http.cc index ba86aa6b6..dbf2d1b43 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -58,6 +58,7 @@ unsigned long PipelineDepth = 10; unsigned long TimeOut = 120; bool Debug = false; + // CircleBuf::CircleBuf - Circular input buffer /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -95,7 +96,7 @@ bool CircleBuf::Read(int Fd) // Woops, buffer is full if (InP - OutP == Size) return true; - + // Write the buffer segment int Res; Res = read(Fd,Buf + (InP%Size),LeftRead()); @@ -204,28 +205,23 @@ bool CircleBuf::WriteTillEl(string &Data,bool Single) if (Buf[I%Size] != '\n') continue; ++I; - if (I < InP && Buf[I%Size] == '\r') - ++I; if (Single == false) { - if (Buf[I%Size] != '\n') - continue; - ++I; if (I < InP && Buf[I%Size] == '\r') ++I; + if (I >= InP || Buf[I%Size] != '\n') + continue; + ++I; } - if (I > InP) - I = InP; - Data = ""; while (OutP < I) { unsigned long Sz = LeftWrite(); if (Sz == 0) return false; - if (I - OutP < LeftWrite()) + if (I - OutP < Sz) Sz = I - OutP; Data += string((char *)(Buf + (OutP%Size)),Sz); OutP += Sz;