Hi,

Downloaded the last version LTP to test from CVS repository.

The usage if "pan/pan " as below:
Usage: pan -n name [ -SyAehp ] [ -s starts ] [-t time[s|m|h|d] [ -x nactive
] [ -l logfile ]
      [ -a active-file ] [ -f command-file ] [ -C fail-command-file ] [ -d
debug-level ]
      [-o output-file] [-O output-buffer-directory] [cmd]

The "pan/pan" would failed in segmentation fault with a wrong option "-f
command-file".

[EMAIL PROTECTED]:~/ltp/ltp$ pan/pan  -q  -e -S  -a 1931 -n 1931  -p
-f /tmp/test
pan(1931): open(/tmp/ltp-1931/alltests,O_RDONLY) failed.  errno:2  No such
file or directory
Segmentation fault

Among the options, the "/tmp/test" does not exist.
The solution is to add condition judgements before use the pointer.

Signed-off-by: Jin Bing Guo <[EMAIL PROTECTED]>
--------
diff -ruNp pan.orig/pan.c pan/pan.c
--- pan.orig/pan.c      2008-05-16 23:18:08.000000000 +0800
+++ pan/pan.c     2008-05-16 23:21:05.000000000 +0800
@@ -321,6 +321,8 @@ main(int argc, char **argv)
     }

     coll = get_collection(filename, optind, argc, argv);
+    if(!coll)
+        exit(1);
     if (coll->cnt == 0) {
      fprintf(stderr,
            "pan(%s): Must supply a file collection or a command\n",
@@ -1018,6 +1020,9 @@ get_collection(char *file, int optind, i

     buf = slurp(file);

+    if(!buf)
+        return NULL;
+
     coll = (struct collection *) malloc(sizeof(struct collection));
     coll->cnt = 0;


Best regards!

Jin Bing Guo  郭晋兵
-------------------------------------
"To be professional ..."
                       -- A killer said.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to