aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2022-11-23 09:09:17 -0800
committerCarlos Maiolino <cem@kernel.org>2022-12-09 10:18:19 +0100
commitb84d0823d5653391d8b2d4dcc8d1da40ebe41b28 (patch)
treeacad16c1bf2ae3be5e5906f87ebedb61aebaedc4
parenta946664debbad130ae1b73058be9bc847623e7fd (diff)
downloadxfsprogs-dev-b84d0823d5653391d8b2d4dcc8d1da40ebe41b28.tar.gz
xfs_db: fix octal conversion logic
Fix the backwards boolean logic here, which results in weird behavior. # xfs_db -x -c /dev/sda xfs_db> print fname fname = "\000\000\000\000\000\000\000\000\000\000\000\000" xfs_db> write fname "mo\0h5o" fname = "mo\005o\000\000\000\000\000\000\000\000" xfs_db> print fname fname = "mo\005o\000\000\000\000\000\000\000\000" Notice that we passed in octal-zero, 'h', '5', 'o', but the fs label is set to octal-5, 'o' because of the incorrect loop logic. -Wlogical-op found this one. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Carlos Maiolino <cem@kernel.org>
-rw-r--r--db/write.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/db/write.c b/db/write.c
index 70cb0518d0..6c67e839a9 100644
--- a/db/write.c
+++ b/db/write.c
@@ -479,7 +479,7 @@ convert_oct(
if (arg[count] == '\0')
break;
- if ((arg[count] < '0') && (arg[count] > '7'))
+ if ((arg[count] < '0') || (arg[count] > '7'))
break;
}
@@ -553,7 +553,7 @@ convert_arg(
/* do octal conversion */
if (*ostr == '\\') {
- if (*(ostr + 1) >= '0' || *(ostr + 1) <= '7') {
+ if (*(ostr + 1) >= '0' && *(ostr + 1) <= '7') {
ret = convert_oct(ostr + 1, &octval);
*rbuf++ = octval;
ostr += ret + 1;