1 Star 0 Fork 8

李宁杰/sox

forked from src-openEuler/sox 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
sox-14.4.2-hcom_stopwrite_big_endian_bug_fix.patch 1.48 KB
一键复制 编辑 原始数据 按行查看 历史
Grooooot 提交于 2019-12-17 16:13 . package init
diff --git a/src/hcom.c b/src/hcom.c
index e76820e..fb8de99 100644
--- a/src/hcom.c
+++ b/src/hcom.c
@@ -428,12 +428,19 @@ static int stopwrite(sox_format_t * ft)
{
priv_t *p = (priv_t *) ft->priv;
unsigned char *compressed_data = p->data;
- size_t compressed_len = p->pos;
+ int32_t compressed_len = (int32_t)p->pos;
int rc = SOX_SUCCESS;
+ if (p->pos >> 32 > 0)
+ lsx_warn(
+ "%s: possible data loss"
+ " (the size of data to be written has exceeded its limit)",
+ ft->filename
+ );
+
/* Compress it all at once */
if (compressed_len)
- compress(ft, &compressed_data, (int32_t *)&compressed_len);
+ compress(ft, &compressed_data, &compressed_len);
free(p->data);
/* Write the header */
@@ -447,7 +454,7 @@ static int stopwrite(sox_format_t * ft)
if (lsx_error(ft)) {
lsx_fail_errno(ft, errno, "write error in HCOM header");
rc = SOX_EOF;
- } else if (lsx_writebuf(ft, compressed_data, compressed_len) != compressed_len) {
+ } else if (lsx_writebuf(ft, compressed_data, (size_t) compressed_len) != (size_t) compressed_len) {
/* Write the compressed_data fork */
lsx_fail_errno(ft, errno, "can't write compressed HCOM data");
rc = SOX_EOF;
@@ -456,7 +463,7 @@ static int stopwrite(sox_format_t * ft)
if (rc == SOX_SUCCESS)
/* Pad the compressed_data fork to a multiple of 128 bytes */
- lsx_padbytes(ft, 128u - (compressed_len % 128));
+ lsx_padbytes(ft, (size_t) 128 - (compressed_len % 128));
return rc;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/li_ning_jie/sox.git
[email protected]:li_ning_jie/sox.git
li_ning_jie
sox
sox
master

搜索帮助