Re: Patch for zero_copy_stream_impl.cc
Here's the patch, attached. On Mon, Oct 20, 2008 at 2:39 PM, Kenton Varda <[EMAIL PROTECTED]> wrote: > Oh, and thanks for catching these! > > > On Mon, Oct 20, 2008 at 2:38 PM, Kenton Varda <[EMAIL PROTECTED]> wrote: > >> Would you care to add some tests to the unit test to check for these bugs? >> Otherwise, I'll do that when I apply these patches. >> >> >> On Mon, Oct 20, 2008 at 2:13 PM, <[EMAIL PROTECTED]> wrote: >> >>> >>> Sorry, I did some reading, and this should the format I send patch in: >>> >>> >>> Index: src/google/protobuf/io/zero_copy_stream_impl.cc >>> === >>> --- src/google/protobuf/io/zero_copy_stream_impl.cc (revision 67) >>> +++ src/google/protobuf/io/zero_copy_stream_impl.cc (working copy) >>> @@ -218,7 +218,8 @@ >>> char junk[4096]; >>> int skipped = 0; >>> while (skipped < count) { >>> -int bytes = Read(junk, min(count, >>> implicit_cast(sizeof(junk; >>> +int bytes = Read(junk, min(count - skipped, >>> + implicit_cast(sizeof(junk; >>> if (bytes <= 0) { >>> // EOF or read error. >>> return skipped; >>> @@ -757,7 +758,7 @@ >>> } >>> >>> bool LimitingInputStream::Next(const void** data, int* size) { >>> - if (limit_ < 0) return false; >>> + if (limit_ <= 0) return false; >>>if (!input_->Next(data, size)) return false; >>> >>> limit_ -= *size; >>> >>> >>> Thanks, >>> Frank >>> >>> On Oct 17, 6:33 am, [EMAIL PROTECTED] wrote: >>> > Whoops, sorry, I meant the other way around >>> > 761c761 >>> > < if (limit_ < 0) return false; >>> > --- >>> > >>> > > if (limit_ <= 0) return false; >>> > >>> > Frank >>> > >>> > On Oct 17, 6:32 am, [EMAIL PROTECTED] wrote: >>> > >>> > > Another patch: >>> > > 761c761 >>> > > < if (limit_ <= 0) return false; >>> > > --- >>> > >>> > > > if (limit_ < 0) return false; >>> > >>> > > Frank >>> > >>> > > On Oct 17, 3:11 am, [EMAIL PROTECTED] wrote: >>> > >>> > > > I found a bug in zero_copy_stream_impl.cc. Here's the patch >>> > > > 221c221,222 >>> > > > < int bytes = Read(junk, min(count, >>> > > > implicit_cast(sizeof(junk; >>> > > > --- >>> > >>> > > > > int bytes = Read(junk, min(count - skipped, >>> > > > > >>> implicit_cast(sizeof(junk; >>> > >>> > > > Frank >>> > >>> > > > PS. Please let me know if this is the right way of sending in >>> patches. >>> >>> >>> >> > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~--- Index: google/protobuf/io/zero_copy_stream_impl.cc === --- google/protobuf/io/zero_copy_stream_impl.cc (revision 67) +++ google/protobuf/io/zero_copy_stream_impl.cc (working copy) @@ -218,7 +218,8 @@ char junk[4096]; int skipped = 0; while (skipped < count) { -int bytes = Read(junk, min(count, implicit_cast(sizeof(junk; +int bytes = Read(junk, min(count - skipped, + implicit_cast(sizeof(junk; if (bytes <= 0) { // EOF or read error. return skipped; @@ -757,7 +758,7 @@ } bool LimitingInputStream::Next(const void** data, int* size) { - if (limit_ < 0) return false; + if (limit_ <= 0) return false; if (!input_->Next(data, size)) return false; limit_ -= *size; Index: google/protobuf/io/zero_copy_stream_unittest.cc === --- google/protobuf/io/zero_copy_stream_unittest.cc (revision 67) +++ google/protobuf/io/zero_copy_stream_unittest.cc (working copy) @@ -90,10 +90,10 @@ // Helper to read a fixed-length array of data from an input stream. int ReadFromInput(ZeroCopyInputStream* input, void* data, int size); // Write a string to the output stream. - void WriteString(ZeroCopyOutputStream* output, const char* str); + void WriteString(ZeroCopyOutputStream* output, const string& str); // Read a number of bytes equal to the size of the given string and checks // that it matches the string. - void ReadString(ZeroCopyInputStream* input, const char* str); + void ReadString(ZeroCopyInputStream* input, const string& str); // Writes some text to the output stream in a particular order. Returns // the number of bytes written, incase the caller needs that to set up an // input stream. @@ -121,6 +121,7 @@ if (!output->Next(&out, &out_size)) { return false; } +EXPECT_GT(out_size, 0); if (in_size <= out_size) { memcpy(out, in, in_size); @@ -145,6 +146,7 @@ if (!input->Next(&in, &in_size)) { return size - out_size; } +EXPECT_GT(in_
Re: Patch for zero_copy_stream_impl.cc
Here's the patch including the patch + unittests. wait I can't send attachment through groups??? sigh I will send it to you via email. Frank On Oct 20, 2:39 pm, "Kenton Varda" <[EMAIL PROTECTED]> wrote: > Oh, and thanks for catching these! > > On Mon, Oct 20, 2008 at 2:38 PM, Kenton Varda <[EMAIL PROTECTED]> wrote: > > Would you care to add some tests to the unit test to check for these bugs? > > Otherwise, I'll do that when I apply these patches. > > > On Mon, Oct 20, 2008 at 2:13 PM, <[EMAIL PROTECTED]> wrote: > > >> Sorry, I did some reading, and this should the format I send patch in: > > >> Index: src/google/protobuf/io/zero_copy_stream_impl.cc > >> === > >> --- src/google/protobuf/io/zero_copy_stream_impl.cc (revision 67) > >> +++ src/google/protobuf/io/zero_copy_stream_impl.cc (working copy) > >> @@ -218,7 +218,8 @@ > >> char junk[4096]; > >> int skipped = 0; > >> while (skipped < count) { > >> - int bytes = Read(junk, min(count, > >> implicit_cast(sizeof(junk; > >> + int bytes = Read(junk, min(count - skipped, > >> + implicit_cast(sizeof(junk; > >> if (bytes <= 0) { > >> // EOF or read error. > >> return skipped; > >> @@ -757,7 +758,7 @@ > >> } > > >> bool LimitingInputStream::Next(const void** data, int* size) { > >> - if (limit_ < 0) return false; > >> + if (limit_ <= 0) return false; > >> if (!input_->Next(data, size)) return false; > > >> limit_ -= *size; > > >> Thanks, > >> Frank > > >> On Oct 17, 6:33 am, [EMAIL PROTECTED] wrote: > >> > Whoops, sorry, I meant the other way around > >> > 761c761 > >> > < if (limit_ < 0) return false; > >> > --- > > >> > > if (limit_ <= 0) return false; > > >> > Frank > > >> > On Oct 17, 6:32 am, [EMAIL PROTECTED] wrote: > > >> > > Another patch: > >> > > 761c761 > >> > > < if (limit_ <= 0) return false; > >> > > --- > > >> > > > if (limit_ < 0) return false; > > >> > > Frank > > >> > > On Oct 17, 3:11 am, [EMAIL PROTECTED] wrote: > > >> > > > I found a bug in zero_copy_stream_impl.cc. Here's the patch > >> > > > 221c221,222 > >> > > > < int bytes = Read(junk, min(count, > >> > > > implicit_cast(sizeof(junk; > >> > > > --- > > >> > > > > int bytes = Read(junk, min(count - skipped, > >> > > > > implicit_cast(sizeof(junk; > > >> > > > Frank > > >> > > > PS. Please let me know if this is the right way of sending in > >> patches. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~---
Re: Patch for zero_copy_stream_impl.cc
Oh, and thanks for catching these! On Mon, Oct 20, 2008 at 2:38 PM, Kenton Varda <[EMAIL PROTECTED]> wrote: > Would you care to add some tests to the unit test to check for these bugs? > Otherwise, I'll do that when I apply these patches. > > > On Mon, Oct 20, 2008 at 2:13 PM, <[EMAIL PROTECTED]> wrote: > >> >> Sorry, I did some reading, and this should the format I send patch in: >> >> >> Index: src/google/protobuf/io/zero_copy_stream_impl.cc >> === >> --- src/google/protobuf/io/zero_copy_stream_impl.cc (revision 67) >> +++ src/google/protobuf/io/zero_copy_stream_impl.cc (working copy) >> @@ -218,7 +218,8 @@ >> char junk[4096]; >> int skipped = 0; >> while (skipped < count) { >> -int bytes = Read(junk, min(count, >> implicit_cast(sizeof(junk; >> +int bytes = Read(junk, min(count - skipped, >> + implicit_cast(sizeof(junk; >> if (bytes <= 0) { >> // EOF or read error. >> return skipped; >> @@ -757,7 +758,7 @@ >> } >> >> bool LimitingInputStream::Next(const void** data, int* size) { >> - if (limit_ < 0) return false; >> + if (limit_ <= 0) return false; >>if (!input_->Next(data, size)) return false; >> >> limit_ -= *size; >> >> >> Thanks, >> Frank >> >> On Oct 17, 6:33 am, [EMAIL PROTECTED] wrote: >> > Whoops, sorry, I meant the other way around >> > 761c761 >> > < if (limit_ < 0) return false; >> > --- >> > >> > > if (limit_ <= 0) return false; >> > >> > Frank >> > >> > On Oct 17, 6:32 am, [EMAIL PROTECTED] wrote: >> > >> > > Another patch: >> > > 761c761 >> > > < if (limit_ <= 0) return false; >> > > --- >> > >> > > > if (limit_ < 0) return false; >> > >> > > Frank >> > >> > > On Oct 17, 3:11 am, [EMAIL PROTECTED] wrote: >> > >> > > > I found a bug in zero_copy_stream_impl.cc. Here's the patch >> > > > 221c221,222 >> > > > < int bytes = Read(junk, min(count, >> > > > implicit_cast(sizeof(junk; >> > > > --- >> > >> > > > > int bytes = Read(junk, min(count - skipped, >> > > > >implicit_cast(sizeof(junk; >> > >> > > > Frank >> > >> > > > PS. Please let me know if this is the right way of sending in >> patches. >> >> >> > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~---
Re: Patch for zero_copy_stream_impl.cc
Would you care to add some tests to the unit test to check for these bugs? Otherwise, I'll do that when I apply these patches. On Mon, Oct 20, 2008 at 2:13 PM, <[EMAIL PROTECTED]> wrote: > > Sorry, I did some reading, and this should the format I send patch in: > > > Index: src/google/protobuf/io/zero_copy_stream_impl.cc > === > --- src/google/protobuf/io/zero_copy_stream_impl.cc (revision 67) > +++ src/google/protobuf/io/zero_copy_stream_impl.cc (working copy) > @@ -218,7 +218,8 @@ > char junk[4096]; > int skipped = 0; > while (skipped < count) { > -int bytes = Read(junk, min(count, > implicit_cast(sizeof(junk; > +int bytes = Read(junk, min(count - skipped, > + implicit_cast(sizeof(junk; > if (bytes <= 0) { > // EOF or read error. > return skipped; > @@ -757,7 +758,7 @@ > } > > bool LimitingInputStream::Next(const void** data, int* size) { > - if (limit_ < 0) return false; > + if (limit_ <= 0) return false; >if (!input_->Next(data, size)) return false; > > limit_ -= *size; > > > Thanks, > Frank > > On Oct 17, 6:33 am, [EMAIL PROTECTED] wrote: > > Whoops, sorry, I meant the other way around > > 761c761 > > < if (limit_ < 0) return false; > > --- > > > > > if (limit_ <= 0) return false; > > > > Frank > > > > On Oct 17, 6:32 am, [EMAIL PROTECTED] wrote: > > > > > Another patch: > > > 761c761 > > > < if (limit_ <= 0) return false; > > > --- > > > > > > if (limit_ < 0) return false; > > > > > Frank > > > > > On Oct 17, 3:11 am, [EMAIL PROTECTED] wrote: > > > > > > I found a bug in zero_copy_stream_impl.cc. Here's the patch > > > > 221c221,222 > > > > < int bytes = Read(junk, min(count, > > > > implicit_cast(sizeof(junk; > > > > --- > > > > > > > int bytes = Read(junk, min(count - skipped, > > > > >implicit_cast(sizeof(junk; > > > > > > Frank > > > > > > PS. Please let me know if this is the right way of sending in > patches. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~---
Re: Patch for zero_copy_stream_impl.cc
Sorry, I did some reading, and this should the format I send patch in: Index: src/google/protobuf/io/zero_copy_stream_impl.cc === --- src/google/protobuf/io/zero_copy_stream_impl.cc (revision 67) +++ src/google/protobuf/io/zero_copy_stream_impl.cc (working copy) @@ -218,7 +218,8 @@ char junk[4096]; int skipped = 0; while (skipped < count) { -int bytes = Read(junk, min(count, implicit_cast(sizeof(junk; +int bytes = Read(junk, min(count - skipped, + implicit_cast(sizeof(junk; if (bytes <= 0) { // EOF or read error. return skipped; @@ -757,7 +758,7 @@ } bool LimitingInputStream::Next(const void** data, int* size) { - if (limit_ < 0) return false; + if (limit_ <= 0) return false; if (!input_->Next(data, size)) return false; limit_ -= *size; Thanks, Frank On Oct 17, 6:33 am, [EMAIL PROTECTED] wrote: > Whoops, sorry, I meant the other way around > 761c761 > < if (limit_ < 0) return false; > --- > > > if (limit_ <= 0) return false; > > Frank > > On Oct 17, 6:32 am, [EMAIL PROTECTED] wrote: > > > Another patch: > > 761c761 > > < if (limit_ <= 0) return false; > > --- > > > > if (limit_ < 0) return false; > > > Frank > > > On Oct 17, 3:11 am, [EMAIL PROTECTED] wrote: > > > > I found a bug in zero_copy_stream_impl.cc. Here's the patch > > > 221c221,222 > > > < int bytes = Read(junk, min(count, > > > implicit_cast(sizeof(junk; > > > --- > > > > > int bytes = Read(junk, min(count - skipped, > > > > implicit_cast(sizeof(junk; > > > > Frank > > > > PS. Please let me know if this is the right way of sending in patches. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~---
Re: Patch for zero_copy_stream_impl.cc
Whoops, sorry, I meant the other way around 761c761 < if (limit_ < 0) return false; --- > if (limit_ <= 0) return false; Frank On Oct 17, 6:32 am, [EMAIL PROTECTED] wrote: > Another patch: > 761c761 > < if (limit_ <= 0) return false; > --- > > > if (limit_ < 0) return false; > > Frank > > On Oct 17, 3:11 am, [EMAIL PROTECTED] wrote: > > > I found a bug in zero_copy_stream_impl.cc. Here's the patch > > 221c221,222 > > < int bytes = Read(junk, min(count, > > implicit_cast(sizeof(junk; > > --- > > > > int bytes = Read(junk, min(count - skipped, > > > implicit_cast(sizeof(junk; > > > Frank > > > PS. Please let me know if this is the right way of sending in patches. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~---
Re: Patch for zero_copy_stream_impl.cc
Another patch: 761c761 < if (limit_ <= 0) return false; --- > if (limit_ < 0) return false; Frank On Oct 17, 3:11 am, [EMAIL PROTECTED] wrote: > I found a bug in zero_copy_stream_impl.cc. Here's the patch > 221c221,222 > < int bytes = Read(junk, min(count, > implicit_cast(sizeof(junk; > --- > > > int bytes = Read(junk, min(count - skipped, > > implicit_cast(sizeof(junk; > > Frank > > PS. Please let me know if this is the right way of sending in patches. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~---
Patch for zero_copy_stream_impl.cc
I found a bug in zero_copy_stream_impl.cc. Here's the patch 221c221,222 < int bytes = Read(junk, min(count, implicit_cast(sizeof(junk; --- > int bytes = Read(junk, min(count - skipped, >implicit_cast(sizeof(junk; Frank PS. Please let me know if this is the right way of sending in patches. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~---