/[ascend]/trunk/ascend/general/ospath.c
ViewVC logotype

Diff of /trunk/ascend/general/ospath.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2554 by jpye, Thu Feb 2 20:14:50 2012 UTC revision 2555 by jpye, Fri Feb 3 00:04:07 2012 UTC
# Line 365  int ospath_chdir(struct FilePath *fp){ Line 365  int ospath_chdir(struct FilePath *fp){
365      FREE(s);      FREE(s);
366      return res;      return res;
367  }  }
368        
369  /**  /**
370      Use getenv() function to retrieve HOME path, or if not set, use      Use getenv() function to retrieve HOME path, or if not set, use
371      the password database and try to retrieve it that way (???)      the password database and try to retrieve it that way (???)
# Line 1257  struct FilePath **ospath_searchpath_new( Line 1257  struct FilePath **ospath_searchpath_new(
1257      char *c;      char *c;
1258      unsigned i;      unsigned i;
1259      struct FilePath **pp;      struct FilePath **pp;
1260      char path1[PATH_MAX];  
1261    #if PATH_MAX < 4096
1262    # define SEARCHPATH_MAX 4096
1263    #else
1264    # define SEARCHPATH_MAX PATH_MAX
1265    #endif
1266    
1267        if(strlen(path) > SEARCHPATH_MAX){
1268            E("Search path is too long, increase SEARCHPATH_MAX in ospath code");
1269            return NULL;
1270        }
1271    
1272        char path1[SEARCHPATH_MAX+1];
1273    
1274      STRTOKVAR(nexttok);      STRTOKVAR(nexttok);
1275    
1276      strncpy(path1,path,PATH_MAX);      strncpy(path1,path,SEARCHPATH_MAX);
1277    
1278      X(path1);      X(path1);
1279      X(PATH_LISTSEP_STR);      X(PATH_LISTSEP_STR);
# Line 1280  struct FilePath **ospath_searchpath_new( Line 1292  struct FilePath **ospath_searchpath_new(
1292      X(p);      X(p);
1293      for(; p!= NULL; p=STRTOK(NULL,PATH_LISTSEP_STR,nexttok)){      for(; p!= NULL; p=STRTOK(NULL,PATH_LISTSEP_STR,nexttok)){
1294          c = (char *)MALLOC(sizeof(char)*(strlen(p)+1));          c = (char *)MALLOC(sizeof(char)*(strlen(p)+1));
1295            /* XXX FIXME what if one path component is longer than PATH_MAX?*/
1296          X(p);          X(p);
1297          STRCPY(c,p);          STRCPY(c,p);
1298          if(n>=LISTMAX){          if(n>=LISTMAX){

Legend:
Removed from v.2554  
changed lines
  Added in v.2555

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22