重现步骤:

  • 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的更多相关文章

  1. php curl 请求302跳转页面

    今天对接支付接口,需要获取支付页面,发现支付商那边给的链接会发送302 跳转,最后发现该方法,绝对给力: <?php $url = 'http://auto.jrj.com.cn/'; $ch ...

  2. PHP使用CURL获取302跳转后的地址实例

    /*返回一个302地址*/     function  curl_post_302($url, $vars) { $ch = curl_init();          curl_setopt($ch ...

  3. PHP 取302跳转后真实 URL 的两种方法

    1 . 第一种,CURL形式[感觉处理略慢,代码偏多] $url = '将跳转的URL'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url) ...

  4. ctfhub web 前置技能(请求方式、302跳转、Cookie)

    第一题:请求方式 打开环境分析题目发现当前请求方式为GET 查看源码发现需要将请求方式改为CTFHUB就可以 使用bp抓包 发送到repeater模块修改请求方式 即可得到flag 第二题:302跳转 ...

  5. asp.net mvc输出自定义404等错误页面,非302跳转。

    朋友问到一个问题,如何输出自定义错误页面,不使用302跳转.当前页面地址不能改变. 还要执行一些代码等,生成一些错误信息,方便用户提交反馈. 500错误,mvc框架已经有现成解决方法: filters ...

  6. asp.net mvc输出自定义404等错误页面,非302跳转

      朋友问到一个问题,如何输出自定义错误页面,不使用302跳转.当前页面地址不能改变. 还要执行一些代码等,生成一些错误信息,方便用户提交反馈. 500错误,mvc框架已经有现成解决方法: filte ...

  7. 三、nginx301跳转302跳转

    301跳转设置: server { listen 80; server_name downcc.com; rewrite ^/(.*) http://www.downcc.com/$1 permane ...

  8. HttpURLConnection碰到连续302跳转的问题的原因及解决方法

    用HttpURLConnection联网的代码: HttpURLConnection conn = null;       URL url = new URL("http://10.0.0. ...

  9. nginx 301 302跳转配置总结

    首先看简单的代码示例,关于nginx 301 302跳转的. 301跳转设置: server { listen 80; server_name 123.com; rewrite ^/(.*) http ...

随机推荐

  1. Oracle数据库字符集解释

    转自:http://www.itpub.net/thread-836643-1-1.html Pl/SQL 执行select * from nls_database_parameters---可以查看 ...

  2. Thrift安装介绍

    一.简介 1.语言库要求 因为thrift支持多语言.所以编译thrift源代码的过程中,会用到该语言的一些类库.如c++的boost.java的jdk等. 那么,在安装thrift过程中,须要对各种 ...

  3. 【Bootstrap】一个兼容IE8、谷歌等主流浏览器的受众门户式风格页面

    上一次写的<[Bootstrap]一个兼容IE8.谷歌等主流浏览器的受众巨幕式风格页面>(点击打开链接) 部分老一辈的需求可能对这样的后现代的风格并不惬意, 没关系,我们全然能够改变布局 ...

  4. 【Sprint3冲刺之前】TDzhushou软件项目测试计划书

    TDzhushou软件测试计划文档 文档编号:2014-5-8 产品版本:1.1 产品名称:TDzhushou 文 档 作 者: 解凤娇       日期:2014-5-4 软件测试计划 目录 第一章 ...

  5. 增加录像时间戳水印、 camera框架介绍

    http://blog.csdn.net/mirkerson/article/details/38920107 http://blog.csdn.net/jimbo_lee/article/detai ...

  6. vs2015终于配置完成了

    安装vs2015,本来应该直接安装vs2015withupdate3的,但是由于当时手上只有vs2015的包,于是直接安装了. 打开C++工程cntk的时候提示需要安装很多东西包括vc编译工具.pyt ...

  7. 在fedora25x86下编译opencv的Android版本的过程记录

    准备材料: 1. 32位的Fedora25(不建议使用64位系统----64位系统下也是可以编译的,这里为了简单起见,考虑使用32位操作系统.事实上,本人在64位操作系统下也做了尝试,也完成了编译.) ...

  8. nginx的源代码分析--间接回调机制的使用和类比

    nginx使用了间接回调机制.结合upstream机制的使用来说明一下,首先明白几个事实: 1)事实上ngxin和下游client的连接使用的是ngx_http_connection_t,每一个连接相 ...

  9. MySQL 更新和删除

    更新和删除的操作SQL语句比較简单,只是要注意使用UPDATE的时候.要注意WEHER条件的限制,以下的语句是仅仅更新id为10005的email地址,假设不加WHERE语句限制,那么将表中全部的em ...

  10. 【转】IDA远程调试 The debugger could not attach to the selected process. irs_recv 等待的操作过时

    IDA连接android_server 选中进程点ok之后 连接不上报错 The debugger could not attach to the selected process. This can ...