1 Star 0 Fork 9

luofeng14/procmail

forked from src-openEuler/procmail 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
procmail-3.22-truncate.patch 1.48 KB
一键复制 编辑 原始数据 按行查看 历史
hexiaowen 提交于 2019-09-30 11:14 . Package init
--- procmail-3.22/src/mailfold.c.truncate 2007-03-27 13:24:05.000000000 +0200
+++ procmail-3.22/src/mailfold.c 2007-03-27 13:25:06.000000000 +0200
@@ -30,6 +30,7 @@
int logopened,rawnonl;
off_t lasttell;
+static int trunced;
static long lastdump;
static volatile int mailread; /* if the mail is completely read in already */
static struct dyna_array confield; /* escapes, concatenations */
@@ -81,6 +82,7 @@
long len;
{ int i;long part;
lasttell=i= -1;SETerrno(EBADF);
+ trunced=0;
if(s>=0)
{ if(ft_lock(type)&&(lseek(s,(off_t)0,SEEK_END),fdlock(s)))
nlog("Kernel-lock failed\n");
@@ -120,13 +122,18 @@
}
writefin:
i=type!=ft_PIPE&&fsync(s)&&errno!=EINVAL; /* EINVAL => wasn't a file */
+ if ((i||len)&&lasttell>=0)
+ { int serrno=errno;
+ if(!ftruncate(s,lasttell)) trunced=1;
+ SETerrno(serrno);
+ }
if(ft_lock(type))
{ int serrno=errno; /* save any error information */
if(fdunlock())
nlog("Kernel-unlock failed\n");
SETerrno(serrno);
}
- i=rclose(s)||i;
+ i=rclose(s)||i; /* if this fails, we should truncate, but it's too late */
} /* return an error even if nothing was to be sent */
return i&&!len?-1:len;
}
@@ -237,7 +244,7 @@
#endif
default:writeerr(buf);
}
- if(lasttell>=0&&!truncate(boxname,lasttell)&&(logopened||verbose))
+ if(lasttell>=0&&trunced&&(logopened||verbose))
nlog("Truncated file to former size\n"); /* undo garbage */
ret0: return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/luofeng14/procmail.git
git@gitee.com:luofeng14/procmail.git
luofeng14
procmail
procmail
master

搜索帮助