X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Finit_src%2Fmain.c;h=0dbbff1493c81db3ce5813f62160ae8ea158f341;hb=d974878ee8bdb568b6c13219495dcfba35e57eaf;hp=a3d737d94d63524f73535e32c82956b515b1a496;hpb=be5123fe1f4aa66b76ce8ef589362ad21b6bbf72;p=tpg%2Facess2.git diff --git a/Usermode/Applications/init_src/main.c b/Usermode/Applications/init_src/main.c index a3d737d9..0dbbff14 100644 --- a/Usermode/Applications/init_src/main.c +++ b/Usermode/Applications/init_src/main.c @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) // No inittab file found, default to: _SysDebug("inittab '%s' is invalid, falling back to one VT", gsInittabPath); - #if 0 + #if 1 for( ;; ) { int pid = SpawnCommand(0, 1, 1, (char *[]){DEFAULT_SHELL, NULL}); @@ -157,7 +157,8 @@ char *ReadQuotedString(FILE *FP) retstr[pos++] = ch; } } - retstr[pos] = '\0'; + if( retstr ) + retstr[pos] = '\0'; return retstr; } @@ -179,6 +180,12 @@ char **ReadCommand(FILE *FP) } ret[pos++] = arg; } while(arg != NULL); + + if( pos == 0 ) + { + free(ret); + return NULL; + } ret[pos] = NULL; return ret; } @@ -196,6 +203,7 @@ void FreeCommand(char **Command) int ProcessInittab(const char *Path) { + int line_num = 0; FILE *fp = fopen(Path, "r"); if( !fp ) @@ -205,6 +213,8 @@ int ProcessInittab(const char *Path) { char cmdbuf[64+1]; + line_num ++; + int rv; if( (rv = fscanf(fp, "%64s%*[ \t]", &cmdbuf)) != 1 ) { _SysDebug("fscanf rv %i != exp 1", rv); @@ -290,13 +300,17 @@ int ProcessInittab(const char *Path) fscanf(fp, " "); continue; lineError: - _SysDebug("label lineError: goto'd"); + _SysDebug("label lineError: goto'd - line %i, cmdbuf='%s'", line_num, cmdbuf); while( !feof(fp) && fgetc(fp) != '\n' ) ; continue ; } fclose(fp); + + if( gpInitPrograms == NULL ) + return 2; + return 0; }