Jump to content

CurlyMo

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Posts posted by CurlyMo

  1. I have a bit of a problem here. I'm fairly new in programming in c but i can write some simple programs.

     

     

    What i wrote is a program that simply encodes my php scripts en decodes them again with the right password. This worked fine when i ran the code just as a c executeable.

    Now i made a php function of this c code. The only problem is, that when i keep executing my php script the memory keeps remembering my previous values:

     

    The code i run throught zend_eval_string (after it's decoded) is:

     

    ?><?PHP

    echo 'good';

    ?>

     

    the output of this script is for the first time:

     

    good

     

    the second time:

     

    good?>good

     

    the third time:

     

    good?>good?>good

     

    and so on.

     

    So the question i have, how can i succesfully fill the memory for just ones and free it after executing my script.

     

     

    The important pieces of code:

     

    char * decrypt(char *content)
    {
    struct hashdata h[NOOFKEY];
    FILE *df1;
    char c, ch, buf[BUFSIZ], line[BUFSIZ];
    int i,x;
    char * rStr = (char *) malloc(strlen(content));
    x = 0;
    strcat(line,"?>");
    for (i=0;i<NOOFKEY;i++)
       readEncryptKey(&h[i]);
    
    strncpy(&c,content+x,1);
    while(c != '\0')
      {
      x++;
      for(i=0;i<NOOFKEY;i++)
         c = hash(&h[i],c);
      sprintf(buf,"%c",c);
      strncpy(&c,content+x,1);
      strcat(line,buf);
      }
    strcpy(rStr,line);
    return rStr;
    free(rStr);
    }
    
    /* implement function that is meant to be made available to PHP */
    ZEND_FUNCTION(meradecode)
    {
    char *parameter;
    int parameter_len;
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &parameter, &parameter_len) == FAILURE)
       return;
    
    zend_eval_string(decrypt(parameter),NULL,"Meraweb Encoder");
    /*RETURN_STRING(decrypt(parameter),0);*/
    free(parameter);
    }
    

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.