aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-20 22:57:26 -0400
committerIan Moffett <ian@osmora.org>2024-03-20 22:57:26 -0400
commit83295ee74070aad3973cdcd8e57d85ad44efc3ce (patch)
treec260b6c4051fd4498b57fe6d1bdb0906cf3d6b99 /sys
parent197bdf24748b03eff9710998b9023376a40971e7 (diff)
kernel: Require len in vcons_putstr()
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/vcons/vcons.c6
-rw-r--r--sys/include/dev/vcons/vcons.h2
-rw-r--r--sys/kern/kern_filedesc.c2
3 files changed, 5 insertions, 5 deletions
diff --git a/sys/dev/vcons/vcons.c b/sys/dev/vcons/vcons.c
index cba0b85..15e97e4 100644
--- a/sys/dev/vcons/vcons.c
+++ b/sys/dev/vcons/vcons.c
@@ -203,12 +203,12 @@ vcons_putch(struct vcons_screen *scr, char c)
* @s: String to write.
*/
int
-vcons_putstr(struct vcons_screen *scr, const char *s)
+vcons_putstr(struct vcons_screen *scr, const char *s, size_t len)
{
int status;
- while (*s != '\0') {
- if ((status = vcons_putch(scr, *(s++))) != 0) {
+ for (size_t i = 0; i < len; ++i) {
+ if ((status = vcons_putch(scr, s[i])) != 0) {
return status;
}
}
diff --git a/sys/include/dev/vcons/vcons.h b/sys/include/dev/vcons/vcons.h
index 9deb656..801075a 100644
--- a/sys/include/dev/vcons/vcons.h
+++ b/sys/include/dev/vcons/vcons.h
@@ -67,7 +67,7 @@ struct vcons_screen {
void vcons_attach(struct vcons_screen *scr);
int vcons_putch(struct vcons_screen *scr, char c);
-int vcons_putstr(struct vcons_screen *scr, const char *s);
+int vcons_putstr(struct vcons_screen *scr, const char *s, size_t len);
void vcons_update_cursor(struct vcons_screen *scr);
#endif /* !_DEV_VCONS_H_ */
diff --git a/sys/kern/kern_filedesc.c b/sys/kern/kern_filedesc.c
index fc3d5ef..dea5a43 100644
--- a/sys/kern/kern_filedesc.c
+++ b/sys/kern/kern_filedesc.c
@@ -217,7 +217,7 @@ write(int fd, const void *buf, size_t count)
/* Is this stdout/stderr? */
if (fd == 1 || fd == 2) {
/* TODO: Update this when we have PTYs */
- vcons_putstr(&g_syslog_screen, in_buf);
+ vcons_putstr(&g_syslog_screen, in_buf, count);
return count;
}