null byte in string causing $_GET to be empty

Discussion in 'PHP' started by DionDev, Mar 24, 2009.

  1. #1
    i have a string - LÙH²räâG3Âd\0(anBì

    this is supposed to be coming from a $_GET variable, called $_GET['info_hash']

    however, the null byte "\0" in this string is causing php to read the variable as empty, as using the empty function tells me it is empty even though it is not.

    what is the workaround for this?
     
    DionDev, Mar 24, 2009 IP
  2. buldozerceto

    buldozerceto Active Member

    Messages:
    1,137
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    88
    #2
    have you tried with isset function?
     
    buldozerceto, Mar 24, 2009 IP
  3. steelaz

    steelaz Peon

    Messages:
    47
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Don't use empty() if you don't have to. It also returns true if value is 0. Use ($str == '') instead.
     
    steelaz, Mar 24, 2009 IP
  4. DionDev

    DionDev Peon

    Messages:
    83
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes I have tried isset. It is being caused by a null byte.

    I am trying to get L%d9H%b2r%e4%e2G3%c2d%05%00%11%28anB%06%ec via the GET variable, any info_hash with a null byte %00 is coming back empty, null, unset when I try and get it using $_GET['info_hash']
     
    DionDev, Mar 25, 2009 IP
  5. Ilyesoft

    Ilyesoft Banned

    Messages:
    164
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Do you get all the string empty ? Did you tried with POST ?
     
    Ilyesoft, Mar 25, 2009 IP
  6. moneyaddick

    moneyaddick Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    try with urlencode(string) before sending the string
     
    moneyaddick, Mar 25, 2009 IP