打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
关于magic_quotes_sybase
关于magic_quotes_sybase

author: ryat#wolvez.org
team:http://www.80vul.com
date:2009-04-14

一 描叙

magic_quotes_gpc为on时,php在注册变量时会调用addslashes()函数处理[既转义单引号、双引号、反斜线和nullbyte],但php.ini中还有另外一个选项影响着magic_quotes_gpc和addslashes()函数:当php.ini设置magic_quotes_sybase为on时会覆盖magic_quotes_gpc为on的处理,然而magic_quotes_sybase仅仅是转义了nullbyte和把'变成了''


二 分析

先来看下addslashes的php源码:

// string.c
PHPAPI char *php_addslashes(char *str, int length, int *new_length, int should_free TSRMLS_DC)
{
return php_addslashes_ex(str, length, new_length, should_free, 0 TSRMLS_CC);
}
...
PHPAPI char *php_addslashes_ex(char *str, int length, int *new_length, int should_free, int ignore_sybase TSRMLS_DC)
{
...
if (!ignore_sybase && PG(magic_quotes_sybase)) {
// 如果ignore_sybase=0[默认为0]且magic_quotes_sybase为on就执行下面的代码
while (source < end) {
switch (*source) {
case '\0':
*target++ = '\\';
*target++ = '0';
break;
case '\'':
*target++ = '\'';
*target++ = '\'';
break;
default:
*target++ = *source;
break;
}
source++;
// 从上面的代码可以看到只是把null变成了\0,'变成了''
}
} else {
// 执行常规的转义
...
由上面的代码可以看到,如果magic_quotes_sybase为on就会覆盖magic_quotes_gpc为on时的默认处理效果[而magic_quotes_sybase仅仅是转义了nullbyte和把'变成了'' :)]


然后我们看看关于magic_quotes_sybase定义的部分:
// main.c
STD_PHP_INI_BOOLEAN("magic_quotes_sybase", "0", PHP_INI_ALL, OnUpdateBool, magic_quotes_sybase, php_core_globals, core_globals)

可以看到,magic_quotes_sybase在php.ini里默认是关闭的,但是属于PHP_INI_ALL类型的指令,那么就可以在.htaccess或者httpd.conf里来更改magic_quotes_sybase的设置了. 如:
// .htaccess
php_flag magic_quotes_sybase on

三 测试代码

   缺

四 实际应用
 
   缺
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
PHP教程 Magic quotes
php.ini中Magic——Quotes_Gpc开关
基于magic
php中addslashes(),htmlspecialchars
addslashes和
php中stripslashes和addslashes的区别
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服