zoukankan      html  css  js  c++  java
  • amfphp传递负数的bug

    There is a weird bug in AMFPHP regarding sending negative integers. If you try and send a number such as -87, it shows up as 4294967209 in php. I did some digging and found on the amfphp forums that it has to do with amfphp's readAmf3Int() method in AMFDeserialzer.php. Here is the updated function that was posted on the forum:

          function readAmf3Int()

              {
                  $res = 0;
                  $int = $this->readByte();
                
                  if($int <128) {
                      return $int;
                  } else {
                      $int = ($int & 0x7f) <<7;
                     
                      $tmp = $this->readByte();
                     
                      if($tmp <128) {
                          $int |= $tmp;
                      }else{
                          $int = ($int | ($tmp & 0x7f)) <<7;
                          $tmp = $this->readByte();
                          if($tmp <128){
                              $int |= $tmp;
                          }else{
                              $int = ($int | ($tmp & 0x7f)) <<8;
                              $tmp = $this->readByte();
                              $int |= $tmp;
                          }
                      }
                  }
           
                  $mask = 1<<28;
                  $res = -($int & $mask) | $int;
           
                  return $res;
              }
  • 相关阅读:
    Java自学-多线程 常见线程方法
    Java自学-多线程 启动一个线程
    Java自学-Lambda 聚合操作
    Java自学-Lambda 方法引用
    Java自学-Lambda 概念
    Java自学-泛型 泛型转型
    Java自学-泛型 通配符
    Java自学-泛型 支持泛型的类
    <VCC笔记> 关于Assertion
    <VCC笔记>VCC简介与安装
  • 原文地址:https://www.cnblogs.com/rooney/p/2314808.html
Copyright © 2011-2022 走看看