Thread: Memory access I can't get

  1. #16
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    the HTTP method i'm using is POST, that is what is set in my html file.
    taking out the
    Code:
    //if( (strcmp(getenv("REQUEST_METHOD"),"POST"))==0){
    and not comparing the environment variable that is sent back - i simply assume it is POST - the code runs. however i get this
    Code:
    Content-type: text/html
    
    <html>
    <head> <title> CGINCform</title> </head>
    <body bgcolor = "purple">
    <center> <h1>CGINC</h1> </center><br>
    Uësâí  @
    <br>Uësâí  @</body>
    </html>
    as you can see, its spitting out garbage somewhere in memory.
    what did you change specifically.
    I have a logVisit function, that i'm going to add to the project that gives me a list of the environment variables. I'm just trying to get it to work now.
    lol. I've never created a project before, usually it is a single source.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  2. #17
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    this is my logVisit function that writes the environment variables to a file and indicates the number of hits.
    Code:
    /* this function logs all the visits to the server  and stores info about the 
    client logging on, using the environment variables. Everything is stored to a file
    for easy access and maintenance. to udate better and save envionemt variables use
    log the time as well.
    */
    #include <stdio.h>
    #include "CGINCform.h" 
    
    
        
    void logVisit(void){
        /* put time value in ptr to chars type as well. and the number of hits */
        FILE *visits;
        int var = 0;
        if ( (visits = fopen("Visits.txt", "a")) == NULL){
            perror("<p>Error");
            return;
            /*would use a return value but function returns void. not needed anyway
            since the return value is used to tell the os if success or not. Possible could
            use EXIT_SUCCESS OR EXIT_FAILURE but the point is it still evaluates to 0 or 1
            so just like ptr2struct->member its REDUNDANT. */
        }   
        //else
       fprintf(visits,"Visit number: %d\n", Hits() ); 
        
        
    /*actually what this means is i can create a static variable for all these vars
    and put the result in a log file to find out who visits when and where. That way I
    can check to see if someone is attemping to ping me interesting */
        /*there are 19 environment variables defined by NCSA. Your particular server 
        may implement more Check your documentation */
          
      char *Evalues[]={
        /*follwing variables are not request specific */
        "SERVER_SOFTWARE",/*name and version of gateway server */ 
        "SERVER_NAME",/*server's hostname or ip addy */
        "GATEWAY_INTERFACE",/*version of the CGI specification of server */
        /*following varaibales are request specifie */
        "SERVER_PROTOCOL",/*name and version of the server protocol */
        "SERVER_PORT",/*port number to which request was sent */
        "REQUEST_METHOD",/*the request method used*/
        "PATH_INFO",/* */
        "PATH_TRANSLATED", /* */
        "SCRIPT_NAME", /*virtual path to script name */
        "QUERY_STRING", /*if method was GET info up to n characters after ? character*/
        "REMOTE_HOST", /*remote host making request */
        "REMOTE_ADDR", /*remote address */
        "AUTH_TYPE", /* if server supports authentication this is tells what protocol used */
        "REMOTE_USER", /*if authuticated this is name of user */
        "REMOTE_IDENT", /* if server supports RFC 931 this var returned */
        "CONTENT_TYPE", /*content type of the data for query using post or put could be text/html or other */
        "CONTENT_LENGTH", /*length of the content to stdin from the post method*/
        "HTTP_ACCEPT", /*MIME TYPES excepted */
        "HTTP_USER_AGENT", /*browser client using */
        /* the following are error logs sent back by the server if anything wrong */
        "REDIRECT_REQUEST", "REDIRECT_URL", "REDIRECT_STATUS",
        /*not mandatory and used if going to store a cookie */
        "SESSION_ID",/* for cookies. */
        "HTTP_COOKIE", /*env var of cookes from the browser */
      
    };
    
    /*iterate through envariables and put to visits.txt.
    entered in should be the environment variable and the value of the
    environment variable */
    
    while (var < 24)
        fprintf(visits,"%s: %s\n", Evalues[var++], getenv(Evalues[var]) );
        
    /* put a separator after done. Actually know could format the file as a htm. */
    
    /*close up shop */
    fputs(EndLine,visits);
    fprintf(visits,"\n");/*this puts an extra line in the file so always starts on a '\n' */
    
    if ( (fclose(visits)) !=0)
       fprintf(stdout,"<h1>UNABLE TO CLOSE FILE</h1>");
       
    else
    
     return;
    }// end of function logVisit
    when i check the logvisit file it gives me this. But i believe it is because I'm accessing the site from local host.
    Code:
    Visit number: 6
    SERVER_SOFTWARE: (null)
    SERVER_NAME: (null)
    GATEWAY_INTERFACE: (null)
    SERVER_PROTOCOL: (null)
    SERVER_PORT: (null)
    REQUEST_METHOD: (null)
    PATH_INFO: (null)
    PATH_TRANSLATED: (null)
    SCRIPT_NAME: (null)
    QUERY_STRING: (null)
    REMOTE_HOST: (null)
    REMOTE_ADDR: (null)
    AUTH_TYPE: (null)
    REMOTE_USER: (null)
    REMOTE_IDENT: (null)
    CONTENT_TYPE: (null)
    CONTENT_LENGTH: (null)
    HTTP_ACCEPT: (null)
    HTTP_USER_AGENT: (null)
    REDIRECT_REQUEST: (null)
    REDIRECT_URL: (null)
    REDIRECT_STATUS: (null)
    SESSION_ID: (null)
    HTTP_COOKIE: (null)
    ===============================================
    so everything is set to null. This is after i've tried to access it via my web server, not just compiling the code.

    note: when i compile the code, it compiles fine - but spitting out garbege -after commenting out
    Code:
    //if( (strcmp(getenv("REQUEST_METHOD"),"POST"))==0){
    and just assuming the HTTP method is post - which it is.

    however when i run try to access the site, press submit to have my cgi data parse by my code my server crashes. and I get a internal server error 500.

    I'm sorry for bringing this on you guys. As it stands now, I may need to incubate and come back, but I had code before that worked somewhat and I'd like to know why this one doesn't.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  3. #18
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by caroundw5h
    what did you change specifically.
    Sorry, I've already forgotten. Here's what I've got at the moment.
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    int decodeUrl(char *str)
    {
       int FIELDS = 0;
       /* only really usable ascii characters are from d32 to d127 but it starts from
       0 to 255. So might as well just parse everything and have the computer do its job */
       char *query = getenv("QUERY_STRING");
       if ( query )
       {
          puts( query );
       }
    
    
       /*this function looks for all the characters '+' and '&' and replaces them with
       a space and a '\n' respectively. It also converts all hexadecimal values to their
       decimal equivalent.
       IMPORTANT: Converting hexx to decimal should not be done on textarea inpput and
       other text type input in case end user meant for that to happen */
       while ( *str )
       {
          if ( *str == '+' )
             *str = ' ';
    
          if ( *str == '&' )
             *str = '\n';
          FIELDS+=1;//counts the number of name vlaue pairs and is sent to getValue()
          str++;
       }
       return FIELDS;
    }
    
    
    char *hex2Dec(char *dst, const char *src)
    {
       int i, j = 0;
       for ( i = 0; src[i]; ++i )
       {
          if ( src[i] != '%' )
          {
             dst[j++] = src[i];
    
             /*only put everythng not a '%' in dest buffer */
          }
          else //if its a '%'
          {
             unsigned ch;
             if ( sscanf(&src[++i/* skip '%' */], "%2x"/*read 2 hex characteres */, &ch) != 1 )
             /*scan data for hex values up to 2field width assign to ch
             this is done because string is a long sequence with no spaces. if spaces
             wouldn't have to use width specifier to tell how many numbers to read
             would automatically read the hex number
             for intelectual curiouslity: &src(i++... */
             {
                return NULL;// if not a hex character retrun null. interesing seems scanf won't
                //act stupid if it's not you can let it do what you want it to.
             }
             dst[j++] = ch;// assign hex to to dest. is hex converted to deciaml then
             ++i; /* with the loop's increment, this will skip the 2nd hex chars
             intellectual curiousity: i++ */
          }
       }
       dst[j] = '\0';
       return dst;
    }
    
    #define MAXFIELDS 100
    /*gonna have to rename nameValue to getvalue which will accept
    getvalue(char *url,int length, char *name)
    can't think of anything else right now.
    */
    char* nameValue(char *URL,int len,char *name )
    {
       char names[MAXFIELDS][MAXFIELDS],temp[MAXFIELDS];
       static char values[MAXFIELDS][MAXFIELDS];
       /*make len already known and rename key to name.
       this function returns the value of a name value pair */
       char *word;
       int ndx;
       int posNum=0;
       int ndx2=0;
       int i;
       /*we use a second counter becuase we'll have to reset it to zero without
       stopping iteration of the url */
       for ( ndx=0;ndx<len;ndx++ )
       {
          temp[ndx2++] = URL[ndx];
    
    
          if ( (URL[ndx] == '=') )
          {
             temp[ndx2-1] = '\0';
             strcpy(names[posNum],temp);
             ndx2=0; //reset buffer to indx 0 for next word
          }
    
          else if ( (URL[ndx] == '\n') )
          {
             temp[ndx2-1] = '\0';
             strcpy(values[posNum],temp);
             ndx2=0;
             posNum+=1;//the word postion only changes after a '\n'
          }
       }
    
    //this prints the name value pairs per line to test it works in stdout
       for ( i=0;i<posNum;i++ )
          printf("%s = %s<br>", names[i],values[i]);
    
       for ( ndx=0;ndx<posNum;ndx++ )
       {
          if ( (strcmp(names[ndx],name)) ==0 )
             word = values[ndx];
    
       }//end of 2nd for
       return word;
    }
    
    char *getvalue(char *name)
    {
       static const char variable[] = "REQUEST_METHOD";
       char *method = getenv(variable);
       if ( method == NULL )
       {
          fprintf(stderr, "%s not found\n", variable);
          return NULL;
       }
       if ( strcmp(method,"POST") == 0 )
       {
          char *url, *Temp, *ValueOfName = NULL;
          unsigned long INPUT;
    
          static const char length[] = "CONTENT_LENGTH";
    
          char *formLength = getenv(length);
          if ( formLength == NULL )
          {
             fprintf(stderr, "%s not found\n", length);
             return NULL;
          }
    
          INPUT = atol(formLength);
          if ( INPUT == 0 )
          {
             fputs("zero length not supported\n", stderr);
             return NULL;
          }
    
          ++INPUT; /* make room for null */
    
          /*make sure room available on system to store info from stdin*/
          url = malloc(INPUT);
          if ( url == NULL )
          {
             fputs("No room Allocated for url\n", stderr);
             return NULL;
          }
    
          Temp = malloc(INPUT);
          if ( Temp == NULL )
          {
             fputs("No room Allocated for Temp\n", stderr);
             return NULL;
          }
    
          if ( fgets(url, INPUT, stdin) !=NULL )
          {
             decodeUrl(url);    /* parses and changes url */
             hex2Dec(Temp,url); /* copies a changed url to temp */
             /*
              * look for the value of name in temp which is up to INPUT
              * and returns its address
              */
             ValueOfName = nameValue(Temp, INPUT, name);
             free(url);/*isn't used anymore copied into temp by hex2Dec*/
             free(Temp);
          }
          return ValueOfName;
       }
       return NULL;
    }
    
    int main(void)
    {
    /*once CGINCform has done all the work - gather input,parse data,decode data
    and return the value of the name looking for. Your now ready to write whatever
    you want back to stdout - that is your webbrowser client. CGINCform returns
    a char * to the value of the name given as its parameter. What you do with it
    is up to you
    */
       char *x;
       char *Identifier;
       Identifier = "Comments";/*store addy of HTML Identifier */
       x=getvalue(Identifier);/*store return addy of getvalue */
    
       /*inform browser of the content type to display */
       printf("Content-type: text/html\n\n");
    
       /*write html code to display */
       printf("<html>\n");
       puts("<head> <title> CGINCform</title> </head>");
       printf("<body bgcolor = \"purple\">\n");
       /*on another module enumerate a list of colors and have user select */
    
       printf("<center> <h1>CGINC</h1> </center>");
       puts("<br>");
    
       if ( x != NULL )
       {
          puts(x);
          printf("<br>%s",x );
       }
       puts("</body>");
       printf("</html>\n");
       /*end of html output */
    
       return 0;
    }
    
    /* my output
    C:\Test>Test
    http://cboard.cprogramming.com/online.php?order=asc&sort=username&pp=25&page=1
    http://cboard.cprogramming.com/online.php?order = asc<br>sort = username<br>pp = 25<br>page = 1<br>Content-type: text/html
    
    <html>
    <head> <title> CGINCform</title> </head>
    <body bgcolor = "purple">
    <center> <h1>CGINC</h1> </center><br>
    http://cboard.cprogramming.com/online.php?order=asc
    sort=username
    pp=25
    page=1
    
    <br>http://cboard.cprogramming.com/online.php?order=asc
    sort=username
    pp=25
    page=1
    </body>
    </html>
    */
    
    /* environment variables (not all)
    C:\Test>set
    CONTENT_LENGTH=100
    REQUEST_METHOD=POST
    */
    Try swapping in this getvalue that does some return-value checking.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  4. #19
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    well. that is interesting. When i swap your getvalue function. the code crashes still. however...I get a REQUEST_METHOD not found error.
    is it possible that its not my code. because I didn't see any difference really with your code and mine, except you did much more error checking.

    interesting.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  5. #20
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    is it possible that its not my code.
    I don't know. Did you steal it from someone? HAHA! Just kidding. No really, what else would it be? A faulty compiler? Not likely...

    Error checking is a great way to debug.
    If you understand what you're doing, you're not learning anything.

  6. #21
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by caroundw5h
    well. that is interesting. When i swap your getvalue function. the code crashes still. however...I get a REQUEST_METHOD not found error.
    is it possible that its not my code. because I didn't see any difference really with your code and mine, except you did much more error checking.
    Did you also make the change in main to check for a null pointer before putsing it? You could also put all of the printing in main inside the if clause to better notice the difference.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  7. #22
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    Quote Originally Posted by itsme86
    I don't know. Did you steal it from someone? HAHA! Just kidding. No really, what else would it be? A faulty compiler? Not likely...

    Error checking is a great way to debug.
    No sadly its all mine - except for the hex2Dec function which i stole from dave a while back - but otherwise its mine, that's probably why it isn't working.

    As to what else could it be. I don't know, it seems that my env variables from the server are not coming through. But one thing i've learned when working with C is when you think its the code - or the computer - its not. Its you using the code and the computer. So i know i did something wrong. I just have to find it again. Maybe i'll leave for another couple months again. :d

    @ dave, I didn't put in the null checking in main, I'm going to do that as soon as i get back from class tonight. BTW. here is my old get value function that compiles flawlessly and gives the following ouput
    Code:
    Content-type: text/html
    
    <html>
    <head> <title> CGINCform</title> </head>
    <body bgcolor = "purple">
    <center> <h1>CGINC</h1> </center><br>
        
    <br>    </body>
    </html>
    obviously i didn't put anything in the cgi form yet.

    however when i run it from the server. I get an server error 500 and my code crashes, which it never did originally. so I'm starting to think i may have a problem with my server. But i'm not sure, because i also have a python script that i use on the backend as well, and it is working fine. yes i'm very confused. anyways here is the original code. I'll check it out agian when i come home tonight.
    Code:
    #include <stdio.h>
    #include <stdlib.h> // for getenv. don't implicitly call this function
    #include <string.h>//for strlen
    #include "CGINCform.h"//for prototype
    /* should be:
        if getenv("REQUEST_METHOD") == "get":
            buf = getenv("QUERY_STRING");
            decodeUrl(buf);
            hexConversion(buf);
            strcpy(form,buff);//put contents in nice named
            free(buff)
            return form
            
        else if getenv("REQUEST_METHOD") == "post";
            length = getenv("CONTENT_LENGTH");
            fgets(buf,length,stdin);
            decode(buf)
            hexConversion(buf);
            strcpy(form,buff)
            return form
            
        else 
          return NULL;
          */
    char* getvalue(char *name){
    		char *valueofName;
          
    /*first check if using gets or post */
    
        char *GETS;/*to store url first. actually since max bytes on any implementation
        is 256 so can do URL[256] or url[512] to be sure
         */
        char *buffer;/*to store url */
        char *buffer2;/*for hex2Dec */
        
        /* store return value of getenv to use */
        if ( ( GETS = getenv("QUERY_STRING") ) !=NULL){
        
      /*allocate space to store contents of QUERY_STRING */
          size_t d = strlen(GETS);
          buffer = malloc (d+1 * sizeof (char) );/*whats the +1 for? */
          strncpy(buffer,GETS,d+1);
         
         /*buffer now contains the contents of the QUERY_STRING*/
          decodeUrl(buffer);
         
          /*allocate a temporary buffer for hex2dec to use. Could be refactored? */
          buffer2 = malloc (d+1 * sizeof(char) );
          /*using malloc is identical to creating a array of size. This means: 
          you can access and change individual elements. it is not treated 
          as a constant */
          
          hex2Dec(buffer2,buffer);
          /*takes a destination and a source char *. returns the modified buffer2*/
          
          /*the following should return value if it is a querystring. INput should be
          a global value */
          //valueofName=nameValue(buffer2,INPUT,name);
          
          /*each call to malloc should be followed by a respective call to free */
          free(buffer);
          free(buffer2);
          /*surprising this doesn't complain. why? does it make GETS  
          a null pointer? test in driver. */
          
          
          //return value 
          
      }   
         
    
      
      else{ 
       
       /* ELSE REQUEST_METHOD == POST so every thing sent to stdin*/
       
     	 char *formLength;
    	 char *url;
    	 char *Temp;
    	 char *ValueOfName;
    	 unsigned long INPUT;/*size of input from stdin*/
    	 
    	 /*get form length and convert to a number.*/
    	 formLength = getenv("CONTENT_LENGTH");
        INPUT = atol(formLength);
        
        /*make sure room available on system to store info from stdin*/
        if ((url = malloc( INPUT * sizeof(char) ) ) == NULL){
         perror("No room Allocated for url");
         return NULL;
        }
       
        if ((Temp = malloc(INPUT * sizeof (char) ) ) == NULL){
        perror("No room allocated for Temp");
        return NULL;
       }
    
      /*get info from stdin and store accordingly */
       
       if( ( fgets(url,INPUT,stdin) ) !=NULL){
       decodeUrl(url);/*parses and changes url */
       hex2Dec(Temp,url); /*copies a changed url to temp*/
       /*look for the value of name in temp which is up to INPUT and returns its address*/
       ValueOfName=nameValue(Temp,INPUT,name);
       free(url);/*isn't used anymore copied into temp by hex2Dec*/
       free(Temp);
      
       }/*end of info processing info from STDIN */
     return ValueOfName;
    }
    }
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  8. #23
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    Alright. I definelty believe something is wrong with the server, or at least I don't know enough about networking to understand this yet. I'm sure you both know more about networking than i do so this might be of interest to you guys.

    I dismanteld my code and started from scratch. I started - and still am - only using the functions logVisit and main in my code.
    I log all vistis to the server to a file and saw all the environment variables and ip's and such. Now all the envrionement variables were being returned by getenv and were being written to the file. Specifically REQUEST_METHOD. So obviously the function was working.

    However because i want to make my code better designed i want to be able to return a msg to the user if the HTTP request method is invalid. Which means a branching if/else statements. Whenever i used the strcmp function in my code, the program crashed on compilation and a server error 500 when the cgi code was called on the backend.

    HOWEVER!!! this was all being done locally. meaning the address in the address bar was 127.0.0.1. When i connected to my site by its domain name ex: http://tantrum-technologies.com/CGINC/ and ran the code. I was able to use strcmp to compare the return value of getenv and use puts to output to stdout - the browser. Even though my code crashed when i compiled it. It did not crash when it was called in the back end.

    If my code crashed on compilation. that is obvioulsy a bad sign. But it obviously has something to do with the way puts and strcmp works. they both search for address and works from there. Could it be that the addresses are given only at run time by the server (if its a stupid question sorry - i'm overexcited and might not be thinking) which is why it doesn't crash when the site is accessed via its domain and running?

    Also do you see any alternatives so that i can test my code locally without having to connect to my site. Even though my site is hosted on my computer. I shouldn't have to access it by its domain name - or should i.

    I also noticed when i make a change in the code, sometimes i refresh the browser or wait a while before the change is refelected in the server, i have no idea what that is about, or why. but i'm sure you both know.
    Last edited by caroundw5h; 03-04-2005 at 03:57 PM.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  9. #24
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    I'm not sure, but I believe that sometimes the POST data comes through stdin instead of getenv(). I wrote my own CGI library before and I used this:
    Code:
    void get_cgi_opts(void)
    {
      CGIOPT *opt;
      char buf[4096], buf2[4096], *p = buf, *q = buf;
    
      fgets(buf, sizeof(buf), stdin);
      if(!*buf)
        strncpy(buf, getenv("QUERY_STRING"), sizeof(buf)-1);
      // etc., etc. down here
    I don't know if that's really helpful to you. It's been a long day at work and my brain is mush
    If you understand what you're doing, you're not learning anything.

  10. #25
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    yeah. supposedly. if the info is sent using the method GET then the info is available from the QUERY_STRING and if the method is POST its goes to stdin.
    Your code is similiar to my first try, Except i changed it to use some branching by checking the REQUEST_METHOD value. Whcih is where I think some of my problems are coming in - at least when i compile it. Now that i know some of the potential problems i'll check out my old code and try those functions, its possible it could be the design of the server - maybe not and i have to work around it.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  11. #26
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    EXCELLENT!!! i think my guess that i was accessing memory the server was to init is right. I recently used the following code to check the PATH environement variable which is independant of the server and my code didn't crash!! WHOOOOOOOO!!!! I'm really happy about that, it was killing me. This experience has taught me a few things and i feel more confident to move on to rebuild and debug my code more efficiently now!!! thanks alot for all your help.
    here is the test code that proved my little guess.
    Code:
    char *Request(void){
    /*if you run this not via the server. the envrionment variables will be null. rememeber the 
    environment variables returned by getenv are from the server, unless it is os specific like path
    -if you output using puts or use strcmp the code crashes locally. if you connect locally ex:
    you put 127.0.0.1 in the title bar, you can't use these two functions. if i connect from 
    tantrum-technologies.com i can use them, though my code when i compile it will crash. I believe
    it has to do with the fact that puts and strcmp has no memory to address yet so it crashes.*/
    /*also the request method is always uppercase: GET and POST */
     char *mesg = getenv("PATH");
     static char *returnd;
     long amnt = strlen(mesg);
     
     if ( (returnd = malloc(amnt * sizeof(char))) ==NULL){
     	 perror("returnd error msg:");
     	 return NULL;
    	 }
    	 
      puts(mesg);
      puts("This message is being generated from the Functin Request.");
    	 
     strcpy(returnd,mesg);
     return returnd;
    }
    subsitute the arguement to getenv as REQUEST_METHOD and the code crashes, because there is no request method yet. its returned by the server!!! Kinda makes sense when you think about. @ me what a moron
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 09-04-2008, 01:27 PM
  2. Direct memory access?
    By _izua_ in forum Windows Programming
    Replies: 4
    Last Post: 08-01-2008, 02:08 AM
  3. Question regarding Memory Leak
    By clegs in forum C++ Programming
    Replies: 29
    Last Post: 12-07-2007, 01:57 AM
  4. Onboard video card memory access
    By HermioneFan in forum Game Programming
    Replies: 1
    Last Post: 05-28-2003, 09:53 AM
  5. Memory Access Error when using Strcpy()
    By fgs3124 in forum C Programming
    Replies: 2
    Last Post: 03-15-2002, 03:07 PM