Skip to content

Commit e74e7f5

Browse files
Fixes for debug-mode TCB naming
Signed-off-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>
1 parent 34355c8 commit e74e7f5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

monitor/src/util.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ char *strcpy(char *restrict dst, const char *restrict src)
9898
dst[i] = src[i];
9999
i++;
100100
}
101+
dst[i] = '\0';
101102

102103
return dst;
103104
}

tool/microkit/src/util.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,14 @@ pub fn monitor_serialise_names(
208208
let name_bytes = name.as_bytes();
209209
let start = (i + 1) * max_name_len;
210210
// Here instead of giving an error we simply take the minimum of the name
211-
// and how large of a name we can encode
212-
let name_length = std::cmp::min(name_bytes.len(), max_name_len);
211+
// and how large of a name we can encode. The name length is one less than
212+
// the maximum since we still have to add the null terminator.
213+
let name_length = std::cmp::min(name_bytes.len(), max_name_len - 1);
213214
let end = start + name_length;
214215
names_bytes[start..end].copy_from_slice(&name_bytes[..name_length]);
215216
// These bytes will be interpreted as a C string, so we must include
216217
// a null-terminator.
217-
names_bytes[start + max_name_len - 1] = 0;
218+
names_bytes[end] = 0;
218219
}
219220

220221
names_bytes

0 commit comments

Comments
 (0)