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 ...
随机推荐
- Golang Map Addressability
http://wangzhezhe.github.io/blog/2016/01/22/golangmapaddressability-dot-md/ 在golang中关于map可达性的问题(addr ...
- linux与python
linux一般都装有python,但是版本不一定,需要自己查看,如果版本过低,需要重装.查看python版本方法,直接在命令行输入 python,此时会进入python命令行,同时会显示python版 ...
- GTK入门学习:布局练习之计算器
接下来,我们做一个布局练习.例如以下图: 我们用表格布局实现,表格布局參考坐标例如以下: 这里我们用到行编辑控件( GtkEntry ). 行编辑的创建: GtkWidget * gtk_entry_ ...
- 构建基于Javascript的移动web CMS——Hello,World
在一篇构建基于Javascript的移动web CMS入门--简单介绍中简单的介绍了关于墨颀CMS的一些原理,其极框架组成.于是開始接着应该说明一下这个CMS是怎样一步步搭建起来. RequireJS ...
- 查看Laravel版本号的三种方法
1:最简单的用命令行实现 php artisan --version 2:查看文件 vendor\laravel\framework\src\Illuminate\Foundation\Applica ...
- 小贝_redis hash类型学习
Redis Hash类型 一.查看hash类型的命令 二.操作hash命令具体解释 一.查看hash类型的命令 1.输入 help@hash 127.0.0.1:6379>help @hash ...
- HDU1009_FatMouse' Trade【贪心】【水题】
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- kubernetes 之QoS服务质量管理
系列目录 在kubernetes中,每个POD都有个QoS标记,通过这个Qos标记来对POD进行服务质量管理.QoS的英文全称为"Quality of Service",中文名为& ...
- 神经网络实现Discuz验证码识别
最近自己尝试了网上的验证码识别代码项目,该小项目见以下链接: https://cuijiahua.com/blog/2018/01/dl_5.html 数据也就用了作者上传的60000张Discuz验 ...
- mac下执行文件出现Permission Denied的解决
mac 下终端访问文件出现“Permission Denied”解决方案: 一个文件有3种权限,读.写.可执行,你这个文件没有可执行权限,需要加上可执行权限. 1. 终端下先 cd到该文件的目录下 2 ...