Exemplo n.º 1
0
char *only_global(char *line,char **current_section,int *global)
{
char *c,*s=line,*globals,*found,*end_section;
globals=(char *)calloc(strlen(line)+1,sizeof(char *));
end_section=(char *)xmalloc(1);
while(1) {
   if (*global) {
      if((found=strstr(s,"<"))==NULL) {
        strncat(globals,s,found-s);
        break;
      }
      if((c=strstr(found,">"))==NULL) break;
      *global=0;
      strncat(globals,s,(found-s));
      *current_section=(char *)xrealloc(*current_section,(c-found)+1);
      memset(*current_section,'\0',(c-found)+1);
      strncat(*current_section,found+1,c-found-1);
      
      s=c;
   }
   if(*current_section!=NULL) {
      end_section=(char *) xrealloc(end_section,strlen(*current_section)+strlen("</")+strlen(">")+1);
      strcpy(end_section,"</");
      strcat(end_section,*current_section);
      strcat(end_section,">");
  
      if((found=istrstr(s,end_section))==NULL) {
	 break;
      }
      s=found+strlen(end_section);
      *global=1;
   }
   }
return(globals);
}
Exemplo n.º 2
0
int fetchsms (char *pdu, int sim)
{
  char answer[ANSWERSIZE];
  int position;
  int beginning;
  int end;
  int  foo,err;

  /* Added for STAC: the input data must be considered tainted! */
  answer[0] = taint();
  
  /* Input magically appears */
  answer[ANSWERSIZE-1] = EOS;

  /* Search for NEEDLE and skip it */
  position=istrstr(answer,NEEDLE);
  if (position==-1)
    return 0;
  beginning = position + NEEDLE_SZ + 1;

  /* BAD */
  r_strcpy(pdu,answer+beginning);
  
  return sim;
}
Exemplo n.º 3
0
int fetchsms (char *pdu, int sim)
{
  char answer[ANSWERSIZE];
  int position;
  int beginning;
  int end;
  int  foo,err;

  /* Added for STAC: the input data must be considered tainted! */
  answer[0] = taint();
  
  /* Input magically appears */
  answer[ANSWERSIZE-1] = EOS;

  /* Search for NEEDLE and skip it */
  position=istrstr(answer,NEEDLE);
  if (position==-1)
    return 0;
  beginning = position + NEEDLE_SZ + 1;

  /* Answer must contain NEEDLE2; we don't need to skip it. */ 
  if (istrstr(answer, NEEDLE2) == -1)
    return 0;

  /* Find (something)\r(something)\r, where each (something) is at
   * least MIN_DIFF characters
   *
   * If we don't find anything satisfying that, abort
   */
  for( end=beginning ; answer[end] != EOS && answer[end] != '\r' ; end++ );
  if ( answer[end] == EOS || end-beginning < MIN_DIFF)
    return 0;
  for( end=end+1 ; answer[end] != EOS && answer[end] !='\r' ; end++ );
  if ( answer[end] == EOS || end-beginning < MIN_DIFF )
    return 0;

  /* Change the last '\r' to an EOS */
  answer[end] = EOS;

  /* BAD */
  r_strcpy(pdu,answer+beginning);
  
  return sim;
}
int fetchsms(char *pdu , int sim ) 
{ char answer[(2 + 2 * 256) + 2] ;
  int position ;
  int beginning ;
  int end ;
  int __retres ;
  
  {answer[0] = (char )taint();
  answer[((2 + 2 * 256) + 2) - 1] = (char)0;
  position = istrstr(answer, "+C");
  if (position == -1) {__retres = 0;
    goto return_label;}
  
  beginning = (position + 2) + 1;
  end = beginning;
  while (1) {if ((int )answer[end] != 0)
             {if (! ((int )answer[end] != '\r')) {break;}
             }
             else {break;}
    
    end ++;}
  
  if ((int )answer[end] == 0) {__retres = 0;
  goto return_label;}
  else {if (end - beginning < 256) {__retres = 0;
          goto return_label;}
  }
  
  end ++;
  while (1) {if ((int )answer[end] != 0)
             {if (! ((int )answer[end] != '\r')) {break;}
             }
             else {break;}
    
    end ++;}
  
  if ((int )answer[end] == 0) {__retres = 0;
  goto return_label;}
  else {if (end - beginning < 256) {__retres = 0;
          goto return_label;}
  }
  
  /* STAC: BAD */
  answer[end] = (char)0;
  /* STAC: BAD */
  r_strcpy(pdu, answer + beginning);
  __retres = sim;
  return_label: /* CIL Label */ 
  return (__retres);}

}
Exemplo n.º 5
0
int fetchsms(char *pdu , int sim ) 
{ char answer[(2 + 2 * 256) + 2] ;
  int position ;
  int beginning ;
  int __retres ;
  
  {answer[0] = (char )taint();
  answer[((2 + 2 * 256) + 2) - 1] = (char)0;
  position = istrstr(answer, "+C");
  if (position == -1) {__retres = 0;
    goto return_label;}
  
  beginning = (position + 2) + 1;
  /* STAC: BAD */
  r_strcpy(pdu, answer + beginning);
  __retres = sim;
  return_label: /* CIL Label */ 
  return (__retres);}

}
Exemplo n.º 6
0
//  ----------------------------------------------------------------------------
void CMultiReaderApp::xProcessNewick(
    const CArgs& args,
    CNcbiIstream& istr,
    CNcbiOstream& ostr)
//  ----------------------------------------------------------------------------
{
    string strTree;
    char c = istr.get();
    while (!istr.eof()) {
        strTree += c;
        if (c == ';') {
            CNcbiIstrstream istrstr(strTree.c_str());
            auto_ptr<TPhyTreeNode>  pTree(ReadNewickTree(istrstr) );
            CRef<CBioTreeContainer> btc = MakeBioTreeContainer(pTree.get());
            xWriteObject(*btc, ostr);
            strTree.clear();
        }
        c = istr.get();
    }
}
Exemplo n.º 7
0
/*
 *
 * reads a variable out the configfile
 * fp           = stream
 * var_name     = variable name
 * section_name = section name
 *                if NULL sections are ignored
 * mode         = 0 -> normal mode
 *                1 -> get only global variables
 * return       = value 
 *              = NULL bij een fout                
 *
 */
char * real_get_config(FILE *fp,char *section_name,char *var_name,int mode)
{

	int l;
	int sect=0,global=1;
	char *r=NULL,*c=NULL,*ss=NULL,s[BUFFER_LEN],*start_section=NULL;
	char *end_section=NULL,*current_section=NULL;

	if(var_name==NULL) 
		return(NULL);

	if(fp==NULL) 
		return NULL;

	fseek(fp,0,SEEK_SET);

	if (s==NULL) 
		return(NULL);

	if (section_name!=NULL) {
   		start_section=(char *)xmalloc(strlen(section_name)+1+strlen("<")+strlen(">"));
   		end_section=(char *)xmalloc(strlen(section_name)+1+strlen("</")+strlen(">"));
   		strcpy(start_section,"<");
   		strcat(start_section,section_name);
   		strcat(start_section,">");
   		strcpy(end_section,"</");
   		strcat(end_section,section_name);
   		strcat(end_section,">");
	}
	else 
		sect=1;

	while (fgets(s,BUFFER_LEN,fp)) {

  		if(!(strrchr(s,'\n'))) 
			{errno=E2BIG;return(NULL);} /* line too long */
  
		s[strlen(s)-1]='\0';
  		cut_rem(s);
  		if(mode==1) { 
			ss=only_global(s,&current_section,&global);
		}
    		else ss=s;
  		if(ss==NULL) return (NULL);
  		if (section_name!=NULL) {
     			if (!sect) {
        			if((c=istrstr(ss,start_section))!=NULL) {
          			ss=c;sect=1;
        			}
     			}
 
   			if (sect) {
      				if ((c=istrstr(ss,end_section))!=NULL) {
         			ss=c;sect=0;
      				}
    			}
  		}
  		if ((sect)&&(ss!=NULL)) {
     			c=mv_2_next(ss);
     			l=strlen(var_name);
     			if (get_item_size(c)==l) {
        			if (!strncasecmp(c,var_name,l)) {
	   				c+=l;
	   				c=mv_2_next(c);
           				if (r==NULL) r=(char *)xmalloc(strlen(c)+1);
              					else r=(char *) xrealloc(r,strlen(c)+1);
              				if(r==NULL) break; 
              				strcpy(r,c);
				}
     			}
  		}
	}

	if((mode==1)&&(ss!=NULL)) 
		xfree(ss); 
	if(start_section!=NULL) 
		xfree(start_section); 
	if(end_section!=NULL)
		xfree(end_section);
	if(current_section!=NULL) 
		xfree(current_section);
	return(r);
}