451

(14 replies, posted in Programming)

Like elbekko and MadHatter have already explained, the NULL byte is used to terminate strings. Here's some history smile

A string, as you might now, is an array of characters. In the ASCII character set, each character is represented by one byte. Each byte has a number between 0 and 255 according to the ASCII table:

http://www.cs.utk.edu/~pham/ascii_table.jpg

As you can see, the character at index zero in the table is called NULL (or NUL, it's the same thing). You can also see that the number zero doesn't represent any particular character. So, if we wanted to store the word "hello" in a string, we would create an array of bytes with the contents:

104,101,108,108,111

But there's a problem with this. If we then want to print that string to the screen, we need to know how many bytes to print. If we don't, we would just continue forever and print whatever appears after this string in the computer's memory. One solution to this problem would be to keep track of how many characters the string contains in a variable in our program. However, that solution isn't very efficient or convenient because then we need an extra variable every time we need to use a string. Instead, we just append the null byte at the end:

104,101,108,108,111,0

Since the number zero doesn't represent any character, we can program our print-to-screen function to continue printing until it encounters the null byte. Most functions that deal with strings work this way. They continue until they encounter the null byte. This is all very convenient, but it has it's own problems. For example, if a program has a string that contains 5 characters followed by the null byte and someone manages to insert a string that is longer than that, we end up with what's called a buffer overrun. But that's a whole different story.

Due to some bugs in PHP, we need to care about null bytes as well. PunBB 1.2.13 contained a patch for a null byte vulnerability that was exploitable by admins only. Here's how it works.

PunBB stores a variable called avatar_path to keep track of where to store avatar images. A malicious administrator (I know, it's almost an oxymoron) can POST a custom form to admin_options.php and set the avatar_path to, for example, "img/avatars/shell.php/%00". %00 is the null byte that has been URL encoded. The administration then uploads an avatar image that has embedded PHP code (for example in the EXIF header). When PunBB receives the file (which it believes to be an image), it will attempt to move the file to the avatar path. The avatar path is img/avatars/shell.php/%00, but due to a bug in PHP, it interprets the null byte as the end of the string which results in the uploaded file being moved to img/avatars/shell.php. We end up with a file called shell.php in the avatars directory that contains PHP code. Not good.

452

(95 replies, posted in News)

SDTux wrote:

OK, it's clear now.
And one more question about link to hdiff in the news - there isn't there direct link in the news - doesn't it strange?

Good point. I added a link to the downloads page.

I agree. Generally, I thought I would dislike a style with that color combination, but I find myself strangly attracted to it smile Good job.

454

(95 replies, posted in News)

SDTux wrote:
Yann wrote:

Nice to ear that our patch got integrated smile Punbb's much, much, much more faster since we applied it wink

Can you tell me more about what exectly make it faster? (it's just my interest)

When searching and showing results as topics (the default), PunBB used to join in the posts table in the query that fetches the topics to display. This join turned out to be useless so we removed it.

455

(95 replies, posted in News)

Keulig wrote:

Thanks for this update.

When will you fix the bug i submitted to you ? (about moderators able to change users' avatars)

Damn! I knew I had forgotten something. Sorry about that Keulig. I'll make sure to get it in the next update.

456

(95 replies, posted in News)

Mark wrote:

News hassent updated on http://punbb.org smile

Thanks. I forgot smile

457

(95 replies, posted in News)

Smartys wrote:

Don't forget to update the announcement wink

I knew you were gonna point that out smile I ran out of nifty things to put in the announcement, so I just updated the message for 1.2.13 smile

458

(95 replies, posted in News)

I guess the old English idiom "when it rains, it pours" applies today :) Nevertheless, I am pleased to announce the release of PunBB 1.2.14. This release addresses a few security problems, fixes a bug or two, adds a search performance tweak and adds stylesheet fixes to fully support the up-and-coming Internet Explorer 7 release. You can find all files related to the update on the downloads page.

Thanks a lot to Nms (nms@wargan.org). Never before have I received such a detailed vulnerability report :) As usual, thanks to Smartys for some of the reports. Finally, thanks to Yann for reporting the search performance tweak.

As some of you might have noticed, I didn't update the copyright notice to include the year 2006 because that would affect all scripts (the GPL preamble) and make the diff's huge. It'll be in 1.3.

459

(30 replies, posted in PunBB 1.2 discussion)

http://dev.punbb.org/changeset/599

The preg_match check in the original patch isn't needed. Thanks to whoever noticed the unnecessary join at skyblog.com and thanks to you Yann for telling us smile

You have to do the same in the tables search_cache and reports. Search install.php for "TEXT NOT NULL DEFAULT ''" and delete everything between TEXT and the comma at the end of the line.

Edit: The fix. I changed the queries for sqlite and pgsql as well (for consistency).

Ran into this on digg today:

http://mydreamapp.com/

They have some pretty cool forums integrated nicely into the site.

Please enable DEBUG mode and post the full error message.

463

(5 replies, posted in PunBB 1.2 troubleshooting)

Does this happen in these forums as well? I've never encountered the problem myself.

464

(6 replies, posted in PunBB 1.2 discussion)

Have a look at the migration tool on the downloads page. Extending it to support phorum shouldn't be all that difficult.

465

(9 replies, posted in General discussion)

It's crazy! I didn't believe it until I read about it on google.com.

466

(6 replies, posted in PunBB 1.2 discussion)

If phorum has a database structure that is somewhat similar to what PunBB has (forums, topics, posts, users etc), it shouldn't be too much work to migrate it manually (if you know some SQL).

467

(3 replies, posted in PunBB 1.2 troubleshooting)

It appears as if the posts get deleted, but that the topic for some reason doesn't.

468

(30 replies, posted in PunBB 1.2 discussion)

Looking into this is on my todo list.

I'm sorry, but I have no idea what you're asking.

470

(13 replies, posted in PunBB 1.2 discussion)

I thought so too. However, for some reason, nothing ever gets written to my error_log.

471

(13 replies, posted in PunBB 1.2 discussion)

Should be fixed now. It's weird that only he got the error message though.

472

(11 replies, posted in PunBB 1.2 bug reports)

StevenBullen wrote:

I personally change it myself. Because I disagree with Rickard on this one.

I'm far from certain that the way I do it (or at least should do it big_smile) is the correct way. If you have any other information on this, I would appreciate a look.

473

(47 replies, posted in General discussion)

Kato wrote:

I never knew Rickard had an extension for FireFox out there...which one is it and what's it do?

Just two very simple ones:

https://addons.mozilla.org/firefox/1472/
https://addons.mozilla.org/firefox/1478/

474

(11 replies, posted in PunBB 1.2 bug reports)

It would be easier, but it wouldn't be correct. The year reflects the "year of publication".

475

(11 replies, posted in PunBB 1.2 bug reports)

Correct. I'll update it for the next release.