php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12561 RE: Bug # 12180
Submitted: 2001-08-03 16:05 UTC Modified: 2001-08-03 16:17 UTC
From: tnovak at lightspeedresearch dot com Assigned:
Status: Closed Package: Output Control
PHP Version: 4.0.6 OS: Redhat Linux, SunOS, ...
Private report: No CVE-ID: None
 [2001-08-03 16:05 UTC] tnovak at lightspeedresearch dot com
Ergh, why isn't there a useful way to reply to bugs?

Anyway... regarding bug #12180, this bug occurs because the pseudo-function smart_str_0 apparently isn't quite so smart :)  In ext/standard/url_scanner_ex.c, it's being called with the parameter &ctx->result; ctx->result.c is unitialized (and ctx->result.len==0) IF the following conditions exist:

- you are using output buffering
- you are using sessions
- you haven't outputted anything
- you don't call ob_end_clean()

This can be replicated with the script:

<? ob_start(); session_start() ?>

I made a quick patch to ext/standard/php_smart_str.h to solve this problem, then realized that it had already been fixed in the latest CVS version (200108031035).  So, I made another patch which adds 2 lines of code to ext/standard/url_scanner_ex.c based on that CVS snapshot:

====== cut ======

diff -ur php-4.0.6.orig/ext/standard/url_scanner_ex.c php-4.0.6/ext/standard/url_scanner_ex.c
--- php-4.0.6.orig/ext/standard/url_scanner_ex.c	Thu Jun 21 02:29:04 2001
+++ php-4.0.6/ext/standard/url_scanner_ex.c	Fri Aug  3 14:29:20 2001
@@ -667,6 +667,8 @@
 	mainloop(ctx, src, srclen);
 
 	*newlen = ctx->result.len;
+	if (!ctx->result.c)
+		smart_str_appendl(&ctx->result, "", 0);
 	smart_str_0(&ctx->result);
 	ctx->result.len = 0;
 	return ctx->result.c;

====== cut ======

You can either patch up 4.0.6 with this, or just use the latest dev snapshot.  I chose to stick with the patched released version, since who knows what bugs have since been introduced into the CVS tree... :)

-Tony Novak
Application Developer, Lightspeed Research LLC
tnovak@lightspeedresearch.com

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-03 16:17 UTC] sniper@php.net
Like you said, fixed in CVS. :)

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 02:01:29 2024 UTC