I have an old CGI that I was trying to edit but it broke when I did.

The users get an email when somebody processes a form, and the users
requested that the 'from' field be set to the customers email address
so they can just hit 'reply' to ask for further info etc...

I only changed 1 line and the code compiles fine but dumps core when run.

Here's the code:
        #define SENDMAIL_PATH "/usr/sbin/sendmail -t"
        #define RECIPIENT "[EMAIL PROTECTED]"
        #define SENDER "[EMAIL PROTECTED]"
        FILE *mail;
        char sendmail[512];
        
        sprintf(sendmail, "%s\n", SENDMAIL_PATH);
        
        mail = popen(sendmail, "w");
        
        fprintf(mail, "To: <%s>\n", RECIPIENT);

       /*
        *the next line used to read:
        *fprintf(mail, "From: <%s>\n", SENDER);
        */
        fprintf(mail, "From: <%s>\n", values[emailIndex]);
        fprintf(mail, "Subject: A new classified marketplace ad.\n");
        fprintf(mail, "\n");
        fprintf(mail, "Name: %s\n", values[nameIndex]);
        fprintf(mail, "Address: %s\n", values[addressIndex]);
        fprintf(mail, "City: %s\n", values[cityIndex]);
        fprintf(mail, "State: %s\n", values[stateIndex]);
        fprintf(mail, "Zip: %s\n", values[zipIndex]);
        fprintf(mail, "\n");
        fprintf(mail, "Email: %s\n", values[emailIndex]);
        fprintf(mail, "Daytime Phone: %s\n", values[day_phoneIndex]);
        fprintf(mail, "Evening Phone: %s\n", values[evening_phoneIndex]);
        fprintf(mail, "Ad Text: %s\n", values[ad_textIndex]);
        fprintf(mail, "Ad Category: %s\n", values[categoryIndex]);
        fprintf(mail, "Subcategory: %s\n", values[subcategoryIndex]);
        fprintf(mail, "Day to run: %s\n", values[day_to_runIndex]);
        fprintf(mail, "Days to run: %s\n", values[days_to_runIndex]);
        fprintf(mail, "Logo: %s\n", values[logoIndex]);
        fprintf(mail, "Special Instructions: %s\n", values[specialIndex]);
        fprintf(mail, "\n.\n");

Reply via email to