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 ...
随机推荐
- ssm 网页
http://stackoverflow.com/questions/14545872/bean-named-xxx-must-be-of-typexxx-but-was-actually-of-ty ...
- ftp的实现
ftp.h #define BUFSIZE 512#define CMDSIZE 64#define ARGSIZE 64#define PASSIVE_ON 0x1 struct ftpcmd{ c ...
- Android相关工具下载(ADT、NDK等等)
一个非常牛掰的网站,可以下载很多Android相关的工具等 网址为: http://www.androiddevtools.cn/
- mini2440使用jlink烧写superboot到norflash
Jlink版本号:J-flash ARM V4.12 J-Flash ARM的配置. 一般说来file-->open project里面会找到一些*.jfl ...
- 服务管理-DNS
DNS服务 DNS(Domain Names System,域名系统),因特网上作为域名和IP地址相互映射的一个分布式数据库,能够使用户更方便的访问互联网,而不用去记住能够被机器直接读取的IP地址.通 ...
- EasyDarwin开源流媒体云平台中boost Base64编解码后与源长度不匹配的bug
本文转自EasyDarwin团队Alex的博客:http://blog.csdn.net/cai6811376 EasyDarwin云平台中部分协议使用了Base64编码昨晚报文通信的载体.比如在对摄 ...
- Maximum Memory and CPU Limitations for Linux Server
grep NR_CPUS /boot/config-`uname -r` [webdev@test apache-flume-1.8.0-bin]$ grep NR_CPUS /boot/config ...
- 2014 ACM-ICPC Beijing Invitational Programming Contest
点击打开链接 Happy Reversal Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO format: %lld J ...
- ES6 新特性之Symbol
Symbol let s1 = Symbol('foo'); let s2 = Symbol('bar'); s1 // Symbol(foo) s2 // Symbol(bar) s1.toStri ...
- BZOJ 1617 [Usaco2008 Mar]River Crossing渡河问题:dp
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1617 题意: Farmer John以及他的N(1 <= N <= 2,500 ...