File tree Expand file tree Collapse file tree 4 files changed +12
-24
lines changed
examples/tutorials/root_of_trust
encryption_service_milestone_one
encryption_service_milestone_three
encryption_service_milestone_two
suspicious_service_milestone_one Expand file tree Collapse file tree 4 files changed +12
-24
lines changed Original file line number Diff line number Diff line change 7
7
#include "libtock/tock.h"
8
8
#include <stdio.h>
9
9
#include <stdlib.h>
10
+ #include <string.h>
10
11
11
12
#include <libtock-sync/interface/console.h>
12
13
#include <libtock/kernel/ipc.h>
@@ -63,12 +64,8 @@ static int setup_logging() {
63
64
static int log_to_screen (const char * message ) {
64
65
returncode_t ret ;
65
66
66
- // Copy up to the log buffer's size of the message, with room for a null byte.
67
- uint16_t len = strnlen (message , sizeof (log_buf ) - 1 );
68
- memcpy (log_buf , message , len );
69
-
70
- // Add the null byte.
71
- log_buf [len ] = '\0' ;
67
+ // Load the log buffer with our message
68
+ strlcpy (log_buf , message , LOG_WIDTH );
72
69
73
70
// Start the logging process.
74
71
ret = ipc_notify_service (screen_service );
Original file line number Diff line number Diff line change 7
7
#include "libtock/tock.h"
8
8
#include <stdio.h>
9
9
#include <stdlib.h>
10
+ #include <string.h>
10
11
11
12
#include <libtock-sync/interface/console.h>
12
13
#include <libtock/kernel/ipc.h>
@@ -66,12 +67,8 @@ static int setup_logging() {
66
67
static int log_to_screen (const char * message ) {
67
68
returncode_t ret ;
68
69
69
- // Copy up to the log buffer's size of the message, with room for a null byte.
70
- uint16_t len = strnlen (message , sizeof (log_buf ) - 1 );
71
- memcpy (log_buf , message , len );
72
-
73
- // Add the null byte.
74
- log_buf [len ] = '\0' ;
70
+ // Load the log buffer with our message
71
+ strlcpy (log_buf , message , LOG_WIDTH );
75
72
76
73
// Start the logging process.
77
74
ret = ipc_notify_service (screen_service );
Original file line number Diff line number Diff line change 7
7
#include "libtock/tock.h"
8
8
#include <stdio.h>
9
9
#include <stdlib.h>
10
+ #include <string.h>
10
11
11
12
#include <libtock-sync/interface/console.h>
12
13
#include <libtock/kernel/ipc.h>
@@ -63,12 +64,8 @@ static int setup_logging() {
63
64
static int log_to_screen (const char * message ) {
64
65
returncode_t ret ;
65
66
66
- // Copy up to the log buffer's size of the message, with room for a null byte.
67
- uint16_t len = strnlen (message , sizeof (log_buf ) - 1 );
68
- memcpy (log_buf , message , len );
69
-
70
- // Add the null byte.
71
- log_buf [len ] = '\0' ;
67
+ // Load the log buffer with our message
68
+ strlcpy (log_buf , message , LOG_WIDTH );
72
69
73
70
// Start the logging process.
74
71
ret = ipc_notify_service (screen_service );
Original file line number Diff line number Diff line change 6
6
#include "libtock/tock.h"
7
7
#include <stdio.h>
8
8
#include <stdlib.h>
9
+ #include <string.h>
9
10
10
11
#include <libtock/kernel/ipc.h>
11
12
@@ -64,12 +65,8 @@ static int setup_logging() {
64
65
static int log_to_screen (const char * message ) {
65
66
returncode_t ret ;
66
67
67
- // Copy up to the log buffer's size of the message, with room for a null byte.
68
- uint16_t len = strnlen (message , sizeof (log_buf ) - 1 );
69
- memcpy (log_buf , message , len );
70
-
71
- // Add the null byte.
72
- log_buf [len ] = '\0' ;
68
+ // Load the log buffer with our message
69
+ strlcpy (log_buf , message , LOG_WIDTH );
73
70
74
71
// Start the logging process.
75
72
ret = ipc_notify_service (screen_service );
You can’t perform that action at this time.
0 commit comments