Hi Petter!
Could you apply patch from attachment?
I added four new variables at the top of spawn() for TTY controlling and
duplicated /dev/null.
Coverity mark my changes as resource leak because I'm not assign
descriptor returned from dup().
Patch for rev 159.
Best regards, Mike.
[Michał Kulling]
Currently in spawn() function is using dup() without return code
validation, i added simple check with additional output to stderr.
Thank you. Applied.
--
Michal Kulling
--- init.c-orig 2014-02-11 20:31:37.688063205 +0100
+++ init.c 2014-02-11 20:38:45.580073375 +0100
@@ -978,6 +978,8 @@
char *args[16]; /* Argv array */
char buf[136]; /* Line buffer */
int f, st; /* Scratch variables */
+ int fdtty1, fdtty2; /* Handlers for TTY controlling dup()*/
+ int fdnull1, fdnull2; /* Handlers for /dev/null dup() */
char *ptr; /* Ditto */
time_t t; /* System time */
int oldAlarm; /* Previous alarm value */
@@ -1111,12 +1113,15 @@
if ((ftty = console_open(O_RDWR|O_NOCTTY)) >= 0) {
/* Take over controlling tty by force */
(void)ioctl(ftty, TIOCSCTTY, 1);
+
+ fdtty1 = dup(ftty);
+ fdtty2 = dup(ftty);
- if(dup(ftty) < 0){
+ if(fdtty1 == -1){
initlog(L_VB, "cannot duplicate console fd");
}
- if(dup(ftty) < 0){
+ if(fdtty2 == -1){
initlog(L_VB, "cannot duplicate console fd");
}
@@ -1189,11 +1194,14 @@
fd = open("/dev/null", O_RDWR);
}
- if(dup(fd) < 0) {
+ fdnull1 = dup(fd);
+ fdnull2 = dup(fd);
+
+ if(fdnull1 == -1) {
initlog(L_VB, "cannot duplicate /dev/null fd");
}
- if(dup(fd) < 0) {
+ if(fdnull2 < 0) {
initlog(L_VB, "cannot duplicate /dev/null fd");
}