I have STATUS_STACK_BUFFER_OVERRUN encountered exception.
Console:
An exception was thrown at 0x000000013FDE716D в prog.exe: 0xC0000005: access violation when reading at 0xFFFFFFFFFFFFFFFF. STATUS_STACK_BUFFER_OVERRUN encountered prog.exe caused a breakpoint. Program "[7636] Curl2.exe" ended with code -1073741510 (0xc000013a).
I get this error when sending a message by email. I want to notice that the error appears only if I send the long text. The text that I want to send takes approximately 8kb on disk in txt file. This is my code to send email:
void sendEmail(const char *server, const char *to, const char *from, const char *subject, const char *message) {
SOCKET sockfd;
WSADATA wsaData;
hostent *host;
sockaddr_in dest;
#define bufsize 300
int sent;
char line[200];
int err;
char *Rec_Buf = (char*)malloc(bufsize + 1);
if (WSAStartup(0x202, &wsaData) != SOCKET_ERROR) {
if ((host = gethostbyname(server)) != NULL) {
memset(&dest, 0, sizeof(dest));
memcpy(&(dest.sin_addr), host->h_addr, host->h_length);
dest.sin_family = host->h_addrtype;
dest.sin_port = htons(25);
sockfd = socket(AF_INET, SOCK_STREAM, 0);
connect(sockfd, (struct sockaddr*)&dest, sizeof(dest));
strcpy(line, "helo me.someplace.com\n");
sent = send(sockfd, line, strlen(line), 0);
Sleep(500);
strcpy(line, "MAIL FROM:<");
strncat(line, from, strlen(from));
strncat(line, ">\n", 3);
sent = send(sockfd, line, strlen(line), 0);
Sleep(500);
strcpy(line, "RCPT TO:<");
strncat(line, to, strlen(to));
strncat(line, ">\n", 3);
sent = send(sockfd, line, strlen(line), 0);
Sleep(500);
strcpy(line, "DATA\n");
sent = send(sockfd, line, strlen(line), 0);
Sleep(500);
strcpy(line, "To:");
strcat(line, to);
strcat(line, "\n");
strcat(line, "From:");
strcat(line, from);
strcat(line, "\n");
strcat(line, "Subject:");
strcat(line, subject);
strcat(line, "\n");
strcat(line, message);
strcat(line, "\r\n.\r\n");
sent = send(sockfd, line, strlen(line), 0);
Sleep(500);
strcpy(line, "quit\n");
sent = send(sockfd, line, strlen(line), 0);
Sleep(500);
err = recv(sockfd, Rec_Buf, bufsize, 0); Rec_Buf[err] = '\0';
fputs(Rec_Buf, file);
fclose(file);
#ifdef WIN32
closesocket(sockfd);
WSACleanup();
#else
close(sockfd);
#endif
}
}
I send mail through aspmx.l.google.com
User contributions licensed under CC BY-SA 3.0