Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions dtls/client-dtls-cid.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ int main (int argc, char** argv)
printf("wolfSSL_read failed");
}
}

/* Add a terminating character to the generic server message */
recvLine[n] = '\0';
fputs(recvLine, stdout);
else {
/* Add a terminating character to the generic server message */
recvLine[n] = '\0';
fputs(recvLine, stdout);
}

close(sockfd);
if ( (sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
Expand Down
17 changes: 13 additions & 4 deletions embedded/tls-info.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,22 @@ static WC_INLINE void ShowX509Ex(WOLFSSL_X509* x509, const char* hdr,
if (ret == WOLFSSL_SUCCESS) {
int i;
int strLen;
char serialMsg[80];
/* worst case: header string + ":xx " (3 chars stride) per serial
byte + null terminator */
char serialMsg[64 + sizeof(serial) * 3 + 1];

/* testsuite has multiple threads writing to stdout, get output
message ready to write once */
strLen = sprintf(serialMsg, " %s", words[3]);
for (i = 0; i < sz; i++)
sprintf(serialMsg + strLen + (i*3), ":%02x ", serial[i]);
strLen = snprintf(serialMsg, sizeof(serialMsg), " %s", words[3]);
if (strLen < 0)
strLen = 0;
for (i = 0; i < sz; i++) {
int remaining = (int)sizeof(serialMsg) - strLen - (i * 3);
if (remaining <= 0)
break;
snprintf(serialMsg + strLen + (i * 3), (size_t)remaining,
":%02x ", serial[i]);
}
printf("%s\n", serialMsg);
}

Expand Down
17 changes: 13 additions & 4 deletions tls/client-tls-cacb.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,22 @@ static void CaCb(unsigned char* der, int sz, int type)
if (ret == WOLFSSL_SUCCESS) {
int i;
int strLen;
char serialMsg[80];
/* worst case: header string + ":xx " (3 chars stride) per serial
byte + null terminator */
char serialMsg[64 + sizeof(serial) * 3 + 1];

/* testsuite has multiple threads writing to stdout, get output
message ready to write once */
strLen = sprintf(serialMsg, "\tSerial Number");
for (i = 0; i < sz; i++)
sprintf(serialMsg + strLen + (i*3), ":%02x ", serial[i]);
strLen = snprintf(serialMsg, sizeof(serialMsg), "\tSerial Number");
if (strLen < 0)
strLen = 0;
for (i = 0; i < sz; i++) {
int remaining = (int)sizeof(serialMsg) - strLen - (i * 3);
if (remaining <= 0)
break;
snprintf(serialMsg + strLen + (i * 3), (size_t)remaining,
":%02x ", serial[i]);
}
printf("%s\n", serialMsg);
}

Expand Down
4 changes: 2 additions & 2 deletions tls/memory-tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static void* client_thread(void* args)
wolfSSL_SetIORecv(cli_ctx, ClientRecv);

WOLFSSL* cli_ssl = wolfSSL_new(cli_ctx);
if (cli_ctx == NULL) err_sys("bad client new");
if (cli_ssl == NULL) err_sys("bad client new");

ret = wolfSSL_connect(cli_ssl);
if (ret != WOLFSSL_SUCCESS) err_sys("bad client tls connect");
Expand Down Expand Up @@ -185,7 +185,7 @@ int main()
wolfSSL_SetIORecv(srv_ctx, ServerRecv);

WOLFSSL* srv_ssl = wolfSSL_new(srv_ctx);
if (srv_ctx == NULL) err_sys("bad server new");
if (srv_ssl == NULL) err_sys("bad server new");

/* start client thread */
pthread_t tid;
Expand Down