Skip to content

Commit 6eb89d1

Browse files
committed
Add boundary check
1 parent 9cb8df2 commit 6eb89d1

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/msclogparser.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ int parse (char * line, size_t len, loglinetype t, logdata * l) {
10991099
int ci = 0;
11001100
int k = pos;
11011101
char client[50];
1102-
while(k < matches[0]-1 && line[k] != ']') {
1102+
while(k < matches[0]-1 && k < len && line[k] != ']') {
11031103
client[ci++] = line[k++];
11041104
}
11051105
client[ci] = '\0';
@@ -1148,7 +1148,7 @@ int parse (char * line, size_t len, loglinetype t, logdata * l) {
11481148
if (hostpos > 0) {
11491149
int k = toffset+1;
11501150
int i = 0;
1151-
while(k < hostpos-1) {
1151+
while(k < hostpos-1 && k < len) {
11521152
tbuff[i++] = line[k++];
11531153
}
11541154
tbuff[i] = '\0';
@@ -1165,7 +1165,7 @@ int parse (char * line, size_t len, loglinetype t, logdata * l) {
11651165
if (hostpos > 0) {
11661166
int k = toffset+1;
11671167
int i = 0;
1168-
while(k < hostpos-1) {
1168+
while(k < hostpos-1 && k < len) {
11691169
tbuff[i++] = line[k++];
11701170
}
11711171
tbuff[i] = '\0';
@@ -1185,7 +1185,7 @@ int parse (char * line, size_t len, loglinetype t, logdata * l) {
11851185
int ci = 0;
11861186
int k = matches[0] + matches[1];
11871187
char client[50];
1188-
while(line[k] != ',') {
1188+
while(k < len && line[k] != ',') {
11891189
client[ci++] = line[k++];
11901190
}
11911191
client[ci] = '\0';

0 commit comments

Comments
 (0)