Skip to content

Commit d79fdc8

Browse files
authored
Merge pull request #162 from linD026/master
Fix the buffer length may cause a read error
2 parents 637e707 + 95a7ca5 commit d79fdc8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

examples/chardev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ enum {
3636
/* Is device open? Used to prevent multiple access to device */
3737
static atomic_t already_open = ATOMIC_INIT(CDEV_NOT_USED);
3838

39-
static char msg[BUF_LEN]; /* The msg the device will give when asked */
39+
static char msg[BUF_LEN + 1]; /* The msg the device will give when asked */
4040

4141
static struct class *cls;
4242

examples/chardev2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ enum {
2828
static atomic_t already_open = ATOMIC_INIT(CDEV_NOT_USED);
2929

3030
/* The message the device will give when asked */
31-
static char message[BUF_LEN];
31+
static char message[BUF_LEN + 1];
3232

3333
static struct class *cls;
3434

0 commit comments

Comments
 (0)