[14672] in Athena Bugs
sgi 8.0F: Using ivcat with stdin input makes it coredump
daemon@ATHENA.MIT.EDU (Patrick McCormick)
Tue Sep 17 19:28:37 1996
To: bugs@MIT.EDU
Cc: 6.837-staff@MIT.EDU
Date: Tue, 17 Sep 1996 19:28:30 EDT
From: Patrick McCormick <pmccormi@MIT.EDU>
System name: wing-commander
Type and version: IP22 8.0F
Display type: NG1
(This was originally submitted by a user in OLC.)
What were you trying to do?
Run ivcat on an Inventor file.
ivcat < /usr/share/data/models/simple/cube.iv
was my example. The same thing happens for most other
Inventor files. Using the "-b" option produces the same result.
What's wrong:
It coredumps.
What should have happened:
ivcat should have output an Inventor file of some sort,
like the manpage says.
Workaround:
Specifying the filename on the command line as in:
ivcat /usr/share/data/models/simple/cube.iv
will do the right thing.
Please describe any relevant documentation references:
man ivcat
Source at:
/usr/share/src/Inventor/tools/ivcat/ivcat.c++
Possible bug:
A quick perusal of the main() function reveals some odd-looking code.
Note the "=>" marked lines. Why this wasn't caught is beyond me.
Maybe someone can recompile it.
if (strcmp(filename, "-") == 0) {
if (isatty(fileno(stdin))) {
fprintf(stderr, "Trying to read from standard input, ");
fprintf(stderr, "but standard input is a tty!\n");
print_usage(argv[0]);
}
in.setFilePointer(stdin);
=> filename = NULL; // Tested later...
}
else if (in.openFile(filename) == FALSE) {
fprintf(stderr, "Could not open file %s\n", filename);
}
// If the filename includes a directory path, add the directory name
// to the list of directories where to look for input files
const char *slashPtr;
char *searchPath = NULL;
=> if ((slashPtr = strrchr(filename, '/')) != NULL) {
=> searchPath = strdup(filename);
=> searchPath[slashPtr - filename] = '\0';
in.addDirectoryFirst(searchPath);
}