Tags 312206 patch
Severity 312206 grave
thanks
Hi,
> Although I cannot imagine a sane reason to divert a file to itself,
me neither.
> ... do not think there is a reason for dpkg-divert to delete the
> diverted file in that case.
I agree with this. So because no reason exists to divert a file to
itself and removing a file if one does so accidentally is a no-go
anyway, it seems more then appropriate to to bail out if src and
destination of the diversion are the same filenames.
Thats what the attached patch does.
On a side note: I raised the severity, because actually deleting
files (without the user requesting it) *is* data loss and thus severity
grave IME.
Best Regards,
Patrick
diff --git a/scripts/dpkg-divert.pl b/scripts/dpkg-divert.pl
index 012be90..7168c17 100755
--- a/scripts/dpkg-divert.pl
+++ b/scripts/dpkg-divert.pl
@@ -270,6 +270,10 @@ sub checkrename {
quit(sprintf(_g("cannot stat old name \`%s': %s"), $rsrc, $!));
(@sdest = lstat($rdest)) || $! == ENOENT ||
quit(sprintf(_g("cannot stat new name \`%s': %s"), $rdest, $!));
+ if ($rsrc eq $rdest) {
+ quit(sprintf(_g("will not divert %s to itself"), $rsrc));
+ }
+
# Unfortunately we have to check for write access in both
# places, just having +w is not enough, since people do
# mount things RO, and we need to fail before we start