html>
********>Bugfix 1.27:
Author: Junmei Wang
Date: 08/21/06

Programs: database

Description: If molname and tmp_file are null strings, severe consequence may be
	     occure if one defines commands like "rm -rf MOLNAME*". The revised
	     version of database exits immediately if molname or tmp_file is null
	     string. The newitoa() function is moved to utility.c.

Fix:  apply the following patch to $ACHOME/antechamber/database.c 

------------------------------------------------------------------------------
*** database.c	2006-08-17 17:23:40.000000000 -0500
--- database.c	2006-08-22 10:03:48.000000000 -0500
***************
*** 20,25 ****
--- 20,26 ----
  # include 
  # include 
  # define MAXCHAR 256
+ # include "utility.c"
  # define COLORTEXT "YES" 
  # define MAXCOMMAND 50
  # define MAXLINE 50
***************
*** 92,180 ****
  void qarn(double  *r,double  p[],int n) ;
  void randomnum (int);
  
- void newitoa(long num, char *str)
- {
-         int i = 0;
-         int j;
-         long tmpint, mod;
-         char tmpchar[MAXCHAR];
-         strcpy(str, "");
-         while (num >= 10) {
-                 tmpint = num / 10;
-                 mod = num - tmpint * 10;
-                 switch (mod) {
-                 case 0:
-                         tmpchar[i] = '0';
-                         break;
-                 case 1:
-                         tmpchar[i] = '1';
-                         break;
-                 case 2:
-                         tmpchar[i] = '2';
-                         break;
-                 case 3:
-                         tmpchar[i] = '3';
-                         break;
-                 case 4:
-                         tmpchar[i] = '4';
-                         break;
-                 case 5:
-                         tmpchar[i] = '5';
-                         break;
-                 case 6:
-                         tmpchar[i] = '6';
-                         break;
-                 case 7:
-                         tmpchar[i] = '7';
-                         break;
-                 case 8:
-                         tmpchar[i] = '8';
-                         break;
-                 case 9:
-                         tmpchar[i] = '9';
-                         break;
-                 }
-                 i++;
-                 num = tmpint;
-         }
-         switch (num) {
-         case 0:
-                 tmpchar[i] = '0';
-                 break;
-         case 1:
-                 tmpchar[i] = '1';
-                 break;
-         case 2:
-                 tmpchar[i] = '2';
-                 break;
-         case 3:
-                 tmpchar[i] = '3';
-                 break;
-         case 4:
-                 tmpchar[i] = '4';
-                 break;
-         case 5:
-                 tmpchar[i] = '5';
-                 break;
-         case 6:
-                 tmpchar[i] = '6';
-                 break;
-         case 7:
-                 tmpchar[i] = '7';
-                 break;
-         case 8:
-                 tmpchar[i] = '8';
-                 break;
-         case 9:
-                 tmpchar[i] = '9';
-                 break;
-         }
-         i++;
-         for (j = 0; j < i; j++)
-                 str[j] = tmpchar[i - j - 1];
-         str[i] = '\0';
- }
- 
  void calendar(int* year,
           int* month,
           int* day,
--- 93,98 ----
***************
*** 254,259 ****
--- 172,181 ----
                                  && str[i + 2] == 'P' && str[i + 3] == 'F'
                                  && str[i + 4] == 'I' && str[i + 5] == 'L'
                                  && str[i + 6] == 'E') {
+ 				if(spaceline(tmp_file) == 1) {
+ 					fprintf(stderr, "ERROR: TMPFILE is null string, exit");
+ 					exit (0);
+ 				}
                                  strcat(newstr, tmp_file);
                                  i += 7;
                          }
***************
*** 261,266 ****
--- 183,192 ----
                                  && str[i + 2] == 'L' && str[i + 3] == 'N'
                                  && str[i + 4] == 'A' && str[i + 5] == 'M'
                                  && str[i + 6] == 'E') {
+ 				if(spaceline(molname) == 1) {
+ 					fprintf(stderr, "ERROR: MOLNAME is null string, exit");
+ 					exit (0);
+ 				}
                                  strcat(newstr, molname);
                                  i += 7;
                          }
***************
*** 283,288 ****
--- 209,218 ----
  				&& commandstr[i + 2] == 'P' && commandstr[i + 3] == 'F'
  				&& commandstr[i + 4] == 'I' && commandstr[i + 5] == 'L'
  				&& commandstr[i + 6] == 'E') {
+ 				if(spaceline(tmp_file) == 1) {
+ 					fprintf(stderr, "ERROR: TMPFILE is null string, exit");
+ 					exit (0);
+ 				}
  				strcat(realcommand, tmp_file);
  				i += 7;
  			}
***************
*** 290,295 ****
--- 220,229 ----
  				&& commandstr[i + 2] == 'L' && commandstr[i + 3] == 'N'
  				&& commandstr[i + 4] == 'A' && commandstr[i + 5] == 'M'
  				&& commandstr[i + 6] == 'E') {
+ 				if(spaceline(molname) == 1) {
+ 					fprintf(stderr, "ERROR: MOLNAME is null string, exit");
+ 					exit (0);
+ 				}
  				strcat(realcommand, molname);
  				i += 7;
  			}

------------------------------------------------------------------------------

Temporary workarounds: none