vfs,avfs: verify an interpreter was found on #! line
. if not, NULL *interp is dereferenced
This commit is contained in:
parent
3fb6c995e0
commit
34a8901eb8
4 changed files with 21 additions and 1 deletions
|
@ -503,6 +503,9 @@ char path[PATH_MAX]; /* path to script file */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!interp)
|
||||||
|
return ENOEXEC;
|
||||||
|
|
||||||
/* Round *stk_bytes up to the size of a pointer for alignment contraints. */
|
/* Round *stk_bytes up to the size of a pointer for alignment contraints. */
|
||||||
*stk_bytes= ((*stk_bytes + PTRSIZE - 1) / PTRSIZE) * PTRSIZE;
|
*stk_bytes= ((*stk_bytes + PTRSIZE - 1) / PTRSIZE) * PTRSIZE;
|
||||||
|
|
||||||
|
|
|
@ -444,6 +444,9 @@ vir_bytes *stk_bytes /* size of initial stack */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!interp)
|
||||||
|
return ENOEXEC;
|
||||||
|
|
||||||
/* Round *stk_bytes up to the size of a pointer for alignment contraints. */
|
/* Round *stk_bytes up to the size of a pointer for alignment contraints. */
|
||||||
*stk_bytes= ((*stk_bytes + PTRSIZE - 1) / PTRSIZE) * PTRSIZE;
|
*stk_bytes= ((*stk_bytes + PTRSIZE - 1) / PTRSIZE) * PTRSIZE;
|
||||||
|
|
||||||
|
|
2
test/run
2
test/run
|
@ -16,7 +16,7 @@ tests=" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
|
||||||
41 42 43 44 45 45-gcc 46 47 48 49 49-gcc 50 \
|
41 42 43 44 45 45-gcc 46 47 48 49 49-gcc 50 \
|
||||||
51 51-gcc 52 52-gcc 53 54 55 56 57 58 59\
|
51 51-gcc 52 52-gcc 53 54 55 56 57 58 59\
|
||||||
60 61 \
|
60 61 \
|
||||||
sh1.sh sh2.sh"
|
sh1.sh sh2.sh interp.sh"
|
||||||
tests_no=`expr 0`
|
tests_no=`expr 0`
|
||||||
|
|
||||||
# Directory must be owned by bin
|
# Directory must be owned by bin
|
||||||
|
|
14
test/testinterp.sh
Executable file
14
test/testinterp.sh
Executable file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# See if the system can handle an unexpected whitespace-only interpreter line
|
||||||
|
|
||||||
|
echo -n "Test interpreter "
|
||||||
|
|
||||||
|
set -e
|
||||||
|
TMPSH=tst$$.sh
|
||||||
|
rm -f $TMPSH
|
||||||
|
echo '#! ' >$TMPSH
|
||||||
|
chmod 755 $TMPSH
|
||||||
|
./$TMPSH || true
|
||||||
|
rm -f $TMPSH
|
||||||
|
echo "ok"
|
Loading…
Reference in a new issue