[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
a bug in function writeString.
From: |
Gilbert Fine |
Subject: |
a bug in function writeString. |
Date: |
Fri, 31 Aug 2001 14:25:18 +0800 |
Hello,
Because string::data() returns a 'const char *' that not
necessarily null-terminated. Using ostream::operator<< is wrong.
I found this bug when I uploaded a binary file and saved the request
to a file.
This is the code for writeString that is right for me.
==========================================
void
CGICCNS writeString(STDNS ostream& out,
const STDNS string& s)
{
out << s.length() << ' ';
out.write(s.data(), s.length());
}
==========================================
--
Best regards,
Gilbert mailto:address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- a bug in function writeString.,
Gilbert Fine <=