Make WordPress Core

Opened 19 years ago

Closed 17 years ago

#4762 closed enhancement (fixed)

new function: absint()

Reported by: markjaquith Owned by: markjaquith
Priority: normal Milestone: 2.8
Component: Security Version: 2.3
Severity: normal Keywords: int security needs-patch
Cc: Focuses:

Description

There were a few bugs whereby things were being cast to ints and providing a negative int would mess up a query (for instance, with SQL LIMITs). We accept negative ints for post IDs (temporarily), but in all other places that Matt or I could think of, we use positive integers.

function absint($string) {
	return abs(intval($string));
}

We'd then convert all instances of intval() or (int) casting to use absint() (minus post IDs).

Objections? Thoughts?

Attachments (1)

4762.diff​ (533 bytes ) - added by ruckus 19 years ago.
absint doesn't exist yet

Download all attachments as: .zip

Change History (18)

#1 @markjaquith
19 years ago

  • Component Administration → Security
  • Keywords int security added
  • Owner changed from anonymous to markjaquith
  • Status new → assigned

#2 @matt
19 years ago

+1 megapatch.

#3 @markjaquith
19 years ago

(In [6222]) Introducing absint() for casting to an absolute integer. see #4762

#4 @DD32
19 years ago

  • Resolution → fixed
  • Status assigned → closed
  • Type task → enhancement

#5 follow-up: @lloydbudd
19 years ago

  • Resolution fixed
  • Status closed → reopened

Re-opening for markjaquith to close. He might be planning on using that function before closing this ticket.

#6 in reply to: ↑ 5 @DD32
19 years ago

Replying to lloydbudd:

Re-opening for markjaquith to close. He might be planning on using that function before closing this ticket.

Apologies for stepping on anyones toes.

absint() has been put into use in several places (comment/post/taxonomy/functions .php)

#7 @westi
19 years ago

(In [6682]) Switch from abs(intval()) to absint(). See #4762.

@ruckus
19 years ago

absint doesn't exist yet

#9 @ruckus
19 years ago

The absint() function doesn't exist this early, so need to use abs(intval()).

While there, made both sides of the comparison to use abs(intval()) for identical treatment of the non-integer values (e.g. 8M or 32M).

#10 @ruckus
19 years ago

Err, "this early" == in wp-settings.php

#11 @ruckus
19 years ago

  • Cc ruckus added

#12 follow-up: @ryan
19 years ago

(In [6684]) absint is not defined yet. see #4762

#13 in reply to: ↑ 12 @westi
19 years ago

Replying to ryan:

(In [6684]) absint is not defined yet. see #4762

/me slaps wrist... that what I get for doing the change when I'm tired :-(

#14 @westi
19 years ago

  • Keywords needs-patch added

The only place we don't use this now where we have abs(intval()) instead is in wp-settings.php where it is too early and not defined.

There are a number of places where we only use intval() though but these need to be checked carefully so moving to 2.6 for the remaining changes and marking as needs-patch

#15 @ffemtcj
19 years ago

  • Milestone 2.5 → 2.6

#16 @Denis-de-Bernardy
17 years ago

could we close this one as fixed?

#17 @Denis-de-Bernardy
17 years ago

  • Milestone 2.9 → 2.8
  • Resolution → fixed
  • Status reopened → closed

fixed a while ago

Note: See TracTickets for help on using tickets.