Skip to content

Commit f344277

Browse files
committed
Merge pull request #184 from Patater/namespace-bytes-copied
Return the proper number of bytes copied when reading box namespaces
2 parents 6e354f1 + 57de15f commit f344277

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

core/system/src/mpu/vmpu.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,18 @@ static int copy_box_namespace(const char *src, char *dst)
444444

445445
if (src[bytes_copied] == '\0') {
446446
/* We've reached the end of the box namespace. */
447-
break;
447+
++bytes_copied; /* Include the terminating-null in bytes_copied. */
448+
goto done;
448449
}
449450
}
450451

452+
/* We did not find a terminating null in the src. The src has been verified
453+
* in vmpu_box_namespace_from_id as being in the box config table. It is a
454+
* programmer error if the namespace in the box config table is not
455+
* null-terminated, so we halt. */
456+
HALT_ERROR(SANITY_CHECK_FAILED, "vmpu: Box namespace missing terminating-null\r\n");
457+
458+
done:
451459
return bytes_copied;
452460
}
453461

0 commit comments

Comments
 (0)