From 5d9fb0798dd4a7a2598418cf9ed59cc8c5f22985 Mon Sep 17 00:00:00 2001 From: Simon Schubert Date: Fri, 15 Jun 2007 07:02:51 +0000 Subject: [PATCH] Fix conditionals to prevent endless loop. Reported-by: swildner Duh-to: corecode --- bin/cp/utils.c | 4 ++-- bin/mv/mv.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/cp/utils.c b/bin/cp/utils.c index 0416def167..3a4cdd4f6d 100644 --- a/bin/cp/utils.c +++ b/bin/cp/utils.c @@ -32,7 +32,7 @@ * * @(#)utils.c 8.3 (Berkeley) 4/1/94 * $FreeBSD: src/bin/cp/utils.c,v 1.45 2005/02/09 17:37:37 ru Exp $ - * $DragonFly: src/bin/cp/utils.c,v 1.10 2007/06/12 20:56:16 corecode Exp $ + * $DragonFly: src/bin/cp/utils.c,v 1.11 2007/06/15 07:02:51 corecode Exp $ */ #include @@ -169,7 +169,7 @@ copy_file(const FTSENT *entp, int dne) #endif { wtotal = 0; - while ((ssize_t)(rcount = read(from_fd, buf, MAXBSIZE)) != 0) { + while ((ssize_t)(rcount = read(from_fd, buf, MAXBSIZE)) > 0) { for (bufp = buf, wresid = rcount; ; bufp += wcount, wresid -= wcount) { wcount = write(to_fd, bufp, wresid); diff --git a/bin/mv/mv.c b/bin/mv/mv.c index 86b0c60926..cd6d22d6d7 100644 --- a/bin/mv/mv.c +++ b/bin/mv/mv.c @@ -32,7 +32,7 @@ * @(#) Copyright (c) 1989, 1993, 1994 The Regents of the University of California. All rights reserved. * @(#)mv.c 8.2 (Berkeley) 4/2/94 * $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/bin/mv/mv.c,v 1.24.2.6 2004/03/24 08:34:36 pjd Exp $ - * $DragonFly: src/bin/mv/mv.c,v 1.13 2007/06/12 20:56:16 corecode Exp $ + * $DragonFly: src/bin/mv/mv.c,v 1.14 2007/06/15 07:02:51 corecode Exp $ */ #include @@ -274,7 +274,7 @@ fastcopy(const char *from, const char *to, struct stat *sbp) close(from_fd); return (1); } - while ((ssize_t)(nread = read(from_fd, bp, (size_t)blen)) != -1) { + while ((ssize_t)(nread = read(from_fd, bp, (size_t)blen)) > 0) { wcount = write(to_fd, bp, nread); wtotal += wcount; -- 2.41.0