c - Fixing extra 0 on the end of a filename request for tftp - warning: the comparison will always evaluate as ‘false’ for the p

I am trying to apply a patch that was posted a decade ago in the Asterisk forum, detailed here:The prob

I am trying to apply a patch that was posted a decade ago in the Asterisk forum, detailed here:

The problem is that the Cisco IP Communicator softphone software makes a bogus TFTP request for it's config file. As the poster said:

"I fired up Wireshark and got to the bottom of it. There is an extra 0x00 following the filename (or preceding the octet mode, depending on your point of view)"

I applied the recommended patch to tftp-hpa under Debian, the patch is here:

root@phony:~/src/debian/tftp-hpa-5.2+20150808/tftpd#  diff -u tftpd.c.orig tftpd.c
--- tftpd.c.orig        2024-11-16 09:37:52.572659519 -0800
+++ tftpd.c     2024-11-16 09:40:58.595989966 -0800
@@ -1096,6 +1096,11 @@
         }

         argn++;
+
+        /* begin Tad’s playing with the stupid zero that Cisco’s tfpd ignores */
+        if ( (cp+1) == 0) { ++cp;}
+        /* end Tad’s playing with the stupid zero that Cisco’s tfpd ignores */
+
         if (argn == 1) {
             mode = ++cp;
         } else if (argn == 2) {
root@phony:~/src/debian/tftp-hpa-5.2+20150808/tftpd#

I got a compiler error that states:

make[1]: Entering directory '/root/src/debian/tftp-hpa-5.2+20150808/tftpd'
x86_64-linux-gnu-gcc -g -O2 -W -Wall -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wwrite-strings -Wundef -Wshadow -Wsign-compare -pipe -fno-strict-aliasing -I/root/src/debian/tftp-hpa-5.2+20150808 -c tftpd.c
tftpd.c: In function ‘tftp’:
tftpd.c:1101:21: warning: the comparison will always evaluate as ‘false’ for the pointer operand in ‘cp + 1’ must not be NULL [-Waddress]
 1101 |         if ( (cp+1) == 0) { ++cp;}
      |                     ^~

Needless to say, the patch does NOT work. However, if I change the line

if ( (cp+1) == 0) { ++cp;}

to just

{ ++cp;}

then the patch DOES work - tftp skips over the extra 0x00 in the IP Communicator application's TFTP request, then the IP Communicator software loads it's config file and provisions the softphone, and I'm able to make and get calls with it using Asterisk.

(I'm using IP Communicator 8.6.6.0 which is the last version Cisco released. Needless to say, Cisco EOLed this softphone software many years ago. Comments from the peanut gallery about using Cisco's softphone with Asterisk instead of Cisco's UCM, or the general shoddiness of Cisco's programming, will be ignored)

Of course, this does mean now that the tftp server is useless for any other normal TFTP usage.

What I am curious about is the original patch poster's claim that it DID work - a decade ago, of course. I'm assuming that there was some change in C or C++ that back then the compiler made and assumption that made the code work, while now the complier no longer makes that assumption and the code breaks.

I'm not a C programmer but what I assume the mistake is, is instead of comparing the contents of the pointer to 0, it's comparing the pointer itself to 0, to decide whether or not to increment the pointer, and I was wondering how to fix this.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745646042a4637977.html

相关推荐

  • Windows下配置Golang开发环境,并安装配置GoLand IDE

    作者:非妃是公主 专栏:《Golang》 博客地址:https:blog.csdnmyf_666 个性签:顺境不惰,逆境不馁

    1小时前
    00
  • 开发体育直播系统后台权限设计实践分享|ThinkPHP 技术栈落地案例

    今天我们分享的是一套由 东莞梦幻网络科技 自研的体育直播源码,在 ThinkPHP + MySQL 技术栈的加持下,后台权限系统如何从0到1落地,并支撑整个平台稳定运行。一、整体架构设计代码语言:html复制用户端(APPH5P

    1小时前
    20
  • 如何增加 Elasticsearch 中的主分片数量

    要增加现有索引的主分片数量,直接修改是不可能的。因此,如果你想增加主分片的数量,必须重新创建索引。通常有两种方法:_reindex API 和 _split API。在这两种方法中,_split API 通常比 _reindex API 更

    1小时前
    20
  • windows 配置 upx

    ​1、下载:2、解压:解压后​3、配置环境变量,右键我的电脑-——》属性——》高级属性:在Path中添加: D:ProgramFileupx-5.0.0-win644、验证cmd中输入:代码语言:txt复制upx --version

    1小时前
    20
  • 打破常规!支付宝小程序地图功能开发实用技巧,拓展业务场景

    打破常规!支付宝小程序地图功能开发实用技巧,拓展业务场景嘿,各位开发者小伙伴们

    1小时前
    00
  • MySQL 8.4 配置复制

    参考文档:.4enreplication-configuration.html1.先在源数据库主机的myf添加这几项代码语言:javascript代码运行次数:0运行复制[mysqld]server-id = 2binlog_forma

    1小时前
    00
  • MySQL8使用物理文件恢复MyISAM表测试

    我们现场测试一个场景,drop一张MyISAM表后,单独对这表进行物理恢复首先我们看一下secure_file_priv文件目录的位置代码语言:javascript代码运行次数:0运行复制mysql> show global vari

    1小时前
    00
  • AI生态暗战升级,科技巨头铁幕下的终极博弈

    一场围绕AI与智能体的标准、协议及生态的暗战已然蓄势待发。在美剧《权力的游戏》中,不到终局,主角归属始终成谜。如今的AI行业,正上演着同样扣人心弦的戏码。这并非是传统意义上的军事或政治博弈,而是一场围绕AI与智能体的标准、协议及生态展开的暗

    1小时前
    00
  • 2025年最受欢迎的10款免费CRM软件大对比

    在数字化转型浪潮下,越来越多的企业开始重视客户关系管理(CRM)系统。一个高效的CRM不仅能帮助企业理清客户脉络,还能提升销售效率、优化服务体验。2025年,市场上涌现了众多优秀的免费CRM软件,本文将为大家对比10款最受欢迎的产品,助您选

    55分钟前
    00
  • PyMC+AI提示词贝叶斯项目反应IRT理论Rasch分析篮球比赛官方数据:球员能力与位置层级结构研究

    全文链接:tecdat?p=41666在体育数据分析领域不断发展的当下,数据科学家们致力于挖掘数据背后的深层价值,为各行业提供更具洞察力的决策依据。近期,我们团队完成了一项极具意义的咨询项目,旨在通过先进的数据分析手段,深入探究篮球比赛中

    53分钟前
    00
  • HLS最全知识库

    HLS最全知识库副标题-FPGA高层次综合HLS(二)-Vitis HLS知识库高层次综合(High-level Synthesis)简称HLS,指的是将高层次语言描述的逻辑结构,自动转换成低抽象级语言描述的电路模型的过程。对于AMD Xi

    41分钟前
    00
  • 如何打造高效AI智能体?

    作者|Barry Zhang, Anthropic地址|出品|码个蛋(ID:codeegg)整理|陈宇明最近看到了 Anthropic 那篇著名的《Building effective agents》作者之一 Barry Zhang 在 2

    34分钟前
    00
  • 非nvidia卡torchvision报错修复: operator torchvision::nms does not exist

    在Ascend 910b上安装vllm, 会自动把torchaudio和torchvision安装上去.安装前代码语言:shell复制pip list | grep torchtorch

    33分钟前
    00
  • 20 万 POC,直接拿来用,这不是测试,这是拒绝服务!!!

    之前看到很多人分享 github 上的一个项目,自动收录全网 nuclei 模板文件,目前已经 19 万了,如果直接拿来对目标进行漏洞探测,无疑会对目标造成巨大伤害,意味着可能要对目标发起十九万次请求以上,可以说是一次小型的 DDoS 攻击

    31分钟前
    00
  • Prometheus配置docker采集器

    Prometheus 配置 Docker 采集器Prometheus 是一个开源的监控系统和时间序列数据库,广泛用于容器化环境中。通过监控 Docker 容器,用户可以实时获取服务性能、资源使用情况等信息。本文将介绍如何为 Docker 容

    22分钟前
    00
  • 开源在线考试系统

    看到调问已经开始扩展在线考试的场景,试了一下,发现在线考试的基本能力都已经支持了。主要是考试中的各种计分功能,包括对每道题的选项设置分值计算、考试时间限制等,和官方了解了一下,考试中的其他各项能力也在逐步完善,有需求可以随时

    18分钟前
    00
  • Power BI 无公式实现帕累托图表

    帕累托分析(Pareto Analysis),也被称为8020法则、关键少数法则,是一种常用的管理工具,用于识别和处理影响业务的主要因素。看到李伟坚老师在Excel使用Vega实现了花式帕累托(参考:Excel 零公式实现高级帕累托图表)

    17分钟前
    00
  • UCB的硅光MEMS OCS控制技术

    昨天写的旭创与nEye合作了一个64端口硅光OCS一、光电路交换技术概述(一)电交换与分组交换电路交换的概念源于早期的电话交换机,通过物理连接实现设备间的通信,就像早期打电话时,接线员手动连接线路一样。而分组交换则是

    6分钟前
    00
  • 推荐一个轻量级的监控平台并且支持移动端

    简介XUGOU 是基于Cloudflare构建的轻量化监控平台,专精于系统资源监控与可视化状态页面服务。该平台提供英文简体中文双语支持,满足全球化部署需求。面向开发者及中小团队,项目致力于提供高可用性的监控解决方案。核心功能与实现平台功能

    4分钟前
    00
  • 【Docker项目实战】使用Docker部署IT工具箱Team·IDE

    一、Team·IDE介绍1.1 Team·IDE简介Team IDE 是一款集成多种数据库(如 MySQL、Oracle、金仓、达梦、神通等)与分布式系统组件(如 Redis、Zookeeper、Kafka、Elasticsearch)管理

    1分钟前
    00

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信