Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show a warning of possible buffer overflow #572

Merged
merged 1 commit into from
Mar 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions Nette/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ public function __destruct()
*/
public function setCookie($name, $value, $time, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL)
{
if (!headers_sent() && ob_get_level() && ob_get_length()) {
trigger_error("Possible problem: you are sending a cookie while already having some data in output buffer. This may not work if the outputted data grows. Try starting the session earlier.", E_USER_NOTICE);
}

if (headers_sent($file, $line)) {
throw new Nette\InvalidStateException("Cannot set cookie after HTTP headers have been sent" . ($file ? " (output started at $file:$line)." : "."));
}
Expand Down
4 changes: 4 additions & 0 deletions Nette/Http/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,10 @@ public function setStorage(ISessionStorage $storage)
*/
private function sendCookie()
{
if (!headers_sent() && ob_get_level() && ob_get_length()) {
trigger_error("Possible problem: you are starting session while already having some data in output buffer. This may not work if the outputted data grows. Try starting the session earlier.", E_USER_NOTICE);
}

$cookie = $this->getCookieParameters();
$this->response->setCookie(
session_name(), session_id(),
Expand Down