More precisely, let's consider the following program:
+++++
#include <stddef.h>
#include <string.h>
#include <netinet/in.h>
#include <netinet/sctp.h>
#include <arpa/inet.h>
int
main(void)
{
int sock;
struct sockaddr_in addr;
struct sctp_sendv_spa spa;
struct iovec iov = {
.iov_base = "data",
.iov_len = 4
};
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
addr.sin_family = AF_INET;
addr.sin_port = htons(20000);
addr.sin_addr.s_addr = inet_addr("127.0.0.1");
connect(sock, (struct sockaddr *) &addr, sizeof(addr));
memset(&spa, 0, sizeof(spa));
spa.sendv_flags = SCTP_SEND_SNDINFO_VALID | SCTP_SEND_PRINFO_VALID |
SCTP_SEND_AUTHINFO_VALID;
sctp_sendv(sock, &iov, 1, NULL, 0, &spa, sizeof(spa), SCTP_SENDV_SPA, 0);
return 0;
}
+++++
Compile this program:
$ gcc -Wall e.c -o e -lsctp
If you execute the program, a fatal error is raised:
$ ./e
** stack smashing detected ***: terminated
Important note: this error occurs ONLY if the 3 flags are present in field
sendv_flags. If only one or two (no matter which flag(s)) are present in field
sendv_flags, execution produces no error.
More precisely, let's consider the following program:
+++++
#include <stddef.h>
#include <string.h>
#include <netinet/in.h>
#include <netinet/sctp.h>
#include <arpa/inet.h>
int
main(void)
{
int sock;
struct sockaddr_in addr;
struct sctp_sendv_spa spa;
struct iovec iov = {
.iov_base = "data",
.iov_len = 4
};
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
addr.sin_family = AF_INET;
addr.sin_port = htons(20000);
addr.sin_addr.s_addr = inet_addr("127.0.0.1");
connect(sock, (struct sockaddr *) &addr, sizeof(addr));
memset(&spa, 0, sizeof(spa));
spa.sendv_flags = SCTP_SEND_SNDINFO_VALID | SCTP_SEND_PRINFO_VALID |
SCTP_SEND_AUTHINFO_VALID;
sctp_sendv(sock, &iov, 1, NULL, 0, &spa, sizeof(spa), SCTP_SENDV_SPA, 0);
return 0;
}
+++++
Compile this program:
$ gcc -Wall e.c -o e -lsctp
If you execute the program, a fatal error is raised:
$ ./e
** stack smashing detected ***: terminated
Important note: this error occurs ONLY if the 3 flags are present in field
sendv_flags. If only one or two (no matter which flag(s)) are present in field
sendv_flags, execution produces no error.