aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-07-16 23:16:57 -0500
committerRob Landley <rob@landley.net>2019-07-16 23:16:57 -0500
commit25bfbb69be6cb5577285cb58d14b1b0c2a09e7d1 (patch)
treee851fec8775cb214e722e694d611c0f37a459b26
parentfdd58dc338b5d1797bb7f44f2602ed60b1c7b911 (diff)
downloadtoybox-25bfbb69be6cb5577285cb58d14b1b0c2a09e7d1.tar.gz
Fix unaligned access, tweak test suite.
-rwxr-xr-xtests/grep.test4
-rw-r--r--toys/posix/grep.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/tests/grep.test b/tests/grep.test
index 76f406c8..69f8036e 100755
--- a/tests/grep.test
+++ b/tests/grep.test
@@ -69,7 +69,7 @@ testing "-o overlap" "grep -bo aaa" "1:aaa\n" "" "baaaa\n"
testing "-co" "grep -co one input" "1\n" "one one one\n" ""
testing "-nom" "grep -nom 2 one" "1:one\n1:one\n1:one\n2:one\n2:one\n" \
"" "one one one\none one\none"
-testing "-vo" "grep -vo one input" "two\nthree\n" "onetwoonethreeone\n" ""
+toyonly testing "-vo" "grep -vo one input" "two\nthree\n" "onetwoonethreeone\n" ""
testing "no newline" "grep -h one input -" \
"hello one\nthere one\n" "hello one" "there one"
@@ -181,7 +181,7 @@ mkdir dir
echo "hello" > dir/f
mkdir sub
ln -s ../dir sub/link
-testing "" "grep -rh hello sub" "" "" ""
+testing "" "grep -rh hello sub 2>/dev/null || echo err" "err\n" "" ""
testing "" "grep -Rh hello sub" "hello\n" "" ""
rm -rf sub real
diff --git a/toys/posix/grep.c b/toys/posix/grep.c
index 54d72c13..6fd6bd2f 100644
--- a/toys/posix/grep.c
+++ b/toys/posix/grep.c
@@ -283,7 +283,7 @@ static void do_grep(int fd, char *name)
else {
while (dlb) {
struct double_list *dl = dlist_pop(&dlb);
- unsigned *uu = (void *)(dl->data+((strlen(dl->data)+1)|3));
+ unsigned *uu = (void *)(dl->data+(strlen(dl->data)|3)+1);
outline(dl->data, '-', name, lcount-before, uu[0]+1, uu[1]);
free(dl->data);
@@ -326,7 +326,7 @@ static void do_grep(int fd, char *name)
discard = 0;
}
if (discard && TT.B) {
- unsigned *uu, ul = (ulen+1)|3;
+ unsigned *uu, ul = (ulen|3)+1;
line = xrealloc(line, ul+8);
uu = (void *)(line+ul);