krzdzi / libjingle

Automatically exported from code.google.com/p/libjingle
0 stars 0 forks source link

std::bad_alloc exception in pcp example #14

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. run the pcp example program

What is the expected output? What do you see instead?
The program crashes with std::bad_alloc exception.

What version of the product are you using? On what operating system?
libjingle 0.4
Gentoo Linux 
kernel: 2.6.17-gentoo-r4
x86_64 AMD Opteron
gcc 4.1.1

Please provide any additional information below.
The problem is in talk/base/httpbase.cc
bool HttpParser::process_line()

if (MatchHeader(line, nlen, HH_CONTENT_LENGTH)) {
        if (sscanf(value, "%d", &data_size_) != 1) {
          err = HE_PROTOCOL;
          break;
        }
}

data_size_ won't be correct. 
The following code works fine.

if (MatchHeader(line, nlen, HH_CONTENT_LENGTH)) {
        unsigned int temp_size;
        if (sscanf(value, "%d", &temp_size) != 1) {
          err = HE_PROTOCOL;
          break;
        }
        data_size_=temp_size;
}

Original issue reported on code.google.com by peter.fe...@gmail.com on 31 Jul 2007 at 9:10

GoogleCodeExporter commented 9 years ago
I believe it is specifically the 64 bit processor that needs this patch.. the 
size_t
type has 64 bits, and the sscanf("%d") is only setting 32 of them.

Original comment by mattwinter on 13 Nov 2007 at 10:37