From cf213612d23cad67cf991298b2cb238c41a34ed3 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Mon, 17 Nov 2014 08:28:06 -0800 Subject: [PATCH] restore(8): Handle old-format uid/gid better Minor style fixup as well. --- sbin/restore/dirs.c | 2 +- sbin/restore/tape.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c index b2cd8fd..d83a1f6 100644 --- a/sbin/restore/dirs.c +++ b/sbin/restore/dirs.c @@ -626,11 +626,11 @@ setdirmodes(int flags) } ep = lookupino(node.ino); if (command == 'i' || command == 'x') { if (ep == NULL) continue; - if ((flags & FORCE) == 0 && ep->e_flags & EXISTED) { + if ((flags & FORCE) == 0 && (ep->e_flags & EXISTED) != 0) { ep->e_flags &= ~NEW; continue; } if (node.ino == ROOTINO && reply("set owner/mode for '.'") == FAIL) diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c index 225fe32..7072d1e 100644 --- a/sbin/restore/tape.c +++ b/sbin/restore/tape.c @@ -1442,12 +1442,13 @@ gethead(struct s_spcl *buf) /* * If we're restoring a filesystem with the old (FreeBSD 1) * format inodes, copy the uid/gid to the new location */ if (oldinofmt) { - buf->c_uid = buf->c_spare1[1]; - buf->c_gid = buf->c_spare1[2]; + /* Cast to avoid sign-extend (c_spare1 is signed). */ + buf->c_uid = (uint16_t)buf->c_spare1[1]; + buf->c_gid = (uint16_t)buf->c_spare1[2]; } buf->c_magic = FS_UFS2_MAGIC; tapeaddr = buf->c_tapea; if (dflag) accthdr(buf); -- 1.9.3