stdout引发的curl 302跳转 crash
重现步骤:
- 0、开发环境:Windows 7 SP1 64bit, VS2008 SP1
- 1、进程中修改了stdout这个句柄的值:调用了prinft和cout都会修改stdout,TRACE不会修改stdout
- 2、使用curl请求一个会跳转的url(HTTP 跳转的话curl会收到包含302的response header)
- 3、crash
问题影响
- curl版本7.21.7和7.28.1都有这个问题
问题原因和解决方案
很可能是curl的一个bug,目前没有找到完美的解决方案,只能在进程中不要使用printf和cout
代码
如果你调用了printf或者cout,你会发现在curl初始化的时候,调用了这个代码,这个时候的stdout已经被修改了
// code block from url.c
/*
* Initialize the UserDefined fields within a SessionHandle.
* This may be safely called on a new or existing SessionHandle.
*/
CURLcode Curl_init_userdefined(struct UserDefined *set)
{
CURLcode res = CURLE_OK; set->out = stdout; /* default output to stdout */ // linyehui:这个set.out有问题
set->in = stdin; /* default input from stdin */
set->err = stderr; /* default stderr to stderr */
实际crash的地方:
// code block from sendf.c /* Curl_client_write() sends data to the write callback(s) The bit pattern defines to what "streams" to write to. Body and/or header.
The defines are in sendf.h of course. If CURL_DO_LINEEND_CONV is enabled, data is converted IN PLACE to the
local character encoding. This is a problem and should be changed in
the future to leave the original data alone.
*/
CURLcode Curl_client_write(struct connectdata *conn,
int type,
char *ptr,
size_t len)
{
// ...
/* If the previous block of data ended with CR and this block of data is
just a NL, then the length might be zero */
if(len) {
wrote = data->set.fwrite_func(ptr, , len, data->set.out); // linyehui:这个set.out有问题
}
else {
wrote = len;
} // ...
呵呵……
stdout引发的curl 302跳转 crash的更多相关文章
- php curl 请求302跳转页面
今天对接支付接口,需要获取支付页面,发现支付商那边给的链接会发送302 跳转,最后发现该方法,绝对给力: <?php $url = 'http://auto.jrj.com.cn/'; $ch ...
- PHP使用CURL获取302跳转后的地址实例
/*返回一个302地址*/ function curl_post_302($url, $vars) { $ch = curl_init(); curl_setopt($ch ...
- PHP 取302跳转后真实 URL 的两种方法
1 . 第一种,CURL形式[感觉处理略慢,代码偏多] $url = '将跳转的URL'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url) ...
- ctfhub web 前置技能(请求方式、302跳转、Cookie)
第一题:请求方式 打开环境分析题目发现当前请求方式为GET 查看源码发现需要将请求方式改为CTFHUB就可以 使用bp抓包 发送到repeater模块修改请求方式 即可得到flag 第二题:302跳转 ...
- asp.net mvc输出自定义404等错误页面,非302跳转。
朋友问到一个问题,如何输出自定义错误页面,不使用302跳转.当前页面地址不能改变. 还要执行一些代码等,生成一些错误信息,方便用户提交反馈. 500错误,mvc框架已经有现成解决方法: filters ...
- asp.net mvc输出自定义404等错误页面,非302跳转
朋友问到一个问题,如何输出自定义错误页面,不使用302跳转.当前页面地址不能改变. 还要执行一些代码等,生成一些错误信息,方便用户提交反馈. 500错误,mvc框架已经有现成解决方法: filte ...
- 三、nginx301跳转302跳转
301跳转设置: server { listen 80; server_name downcc.com; rewrite ^/(.*) http://www.downcc.com/$1 permane ...
- HttpURLConnection碰到连续302跳转的问题的原因及解决方法
用HttpURLConnection联网的代码: HttpURLConnection conn = null; URL url = new URL("http://10.0.0. ...
- nginx 301 302跳转配置总结
首先看简单的代码示例,关于nginx 301 302跳转的. 301跳转设置: server { listen 80; server_name 123.com; rewrite ^/(.*) http ...
随机推荐
- 第一个Hello,OS World操作系统
来自:清泛网 - http://www.tsingfun.com/html/2015/dev_0804/hello_os_word_my_first_os.html 首先阐述下程序运行的基本原理:计算 ...
- C语言函数的递归和调用
函数记住两点: (1)每个函数运行完才会返回调用它的函数:每个函数运行完才会返回调用它的函数,因此,你可以先看看这个函数不自我调用的条件,也就是fun()中if条件不成立的时候,对吧,不成立的时候就是 ...
- [RFC] Simplifying kernel configuration for distro issues
http://lwn.net/Articles/507276/ From: Linus Torvalds <torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b-A ...
- jsp 下拉框首字母定位可检索
实现效果如图: 页面部分: (1)js中: (2)body中: JAVA代码部分: 控制器Controller中 写一个页面js中调用的方法: 引入jar包:
- 04 svn设置开机启动
一:设置开机启动[dos命令] 格式: sc create 服务名称 binPath=空格"安装目录/svnserve.exe -r 版本库地址目录 --service" star ...
- 在VS2015中增加JQuery引用及智能提示
打开VS2015,从"工具"菜单选择NuGet选项,搜索Jquery,并点击安装. 可以看到解决方案的scripts增加了对应文件的引用 在HTML文件中可以直接引用j ...
- WPF中的数据绑定Data Binding使用小结
完整的数据绑定的语法说明可以在这里查看: http://www.nbdtech.com/Free/WpfBinding.pdf MSDN资料: Data Binding: Part 1 http:// ...
- 1367: [Baltic2004]sequence
1367: [Baltic2004]sequence Time Limit: 20 Sec Memory Limit: 64 MB Submit: 1090 Solved: 432 [Submit ...
- java读取properties文件中参数值
在类文件中加入代码: //config.properties.sysInfo //sysInfo.properties在文件夹的路径为/src/config/properties/sysInfo.pr ...
- Apache http server和tomcat的区别
Apache官方网站:http://www.apache.org/Tomcat官方网站:http://tomcat.apache.org/ 1. Apache是web服务器,Tomcat是应用(jav ...