vfs,avfs: verify an interpreter was found on #! line

. if not, NULL *interp is dereferenced
This commit is contained in:
Ben Gras 2011-12-20 16:20:32 +01:00
parent 3fb6c995e0
commit 34a8901eb8
4 changed files with 21 additions and 1 deletions

View file

@ -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. */
*stk_bytes= ((*stk_bytes + PTRSIZE - 1) / PTRSIZE) * PTRSIZE;

View file

@ -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. */
*stk_bytes= ((*stk_bytes + PTRSIZE - 1) / PTRSIZE) * PTRSIZE;

View file

@ -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 \
51 51-gcc 52 52-gcc 53 54 55 56 57 58 59\
60 61 \
sh1.sh sh2.sh"
sh1.sh sh2.sh interp.sh"
tests_no=`expr 0`
# Directory must be owned by bin

14
test/testinterp.sh Executable file
View 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"