Skip to content

Commit 1617347

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master'
2 parents bd5e4d2 + 530ac34 commit 1617347

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Source/NSHost.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,27 @@
217217
{
218218
NSMutableSet *names = nil;
219219
NSString *key;
220+
size_t len;
220221
char *line = buf;
221222
char *save = 0;
222223
char *addr;
223224
char *name;
224225

226+
/* Detect truncated lines: if the buffer is full and doesn't end
227+
* with a newline, the line was too long. Drain the rest of it
228+
* and skip processing entirely.
229+
*/
230+
len = strlen(buf);
231+
if (len == sizeof(buf) - 1 && buf[len - 1] != '\n')
232+
{
233+
int c;
234+
while ((c = fgetc(fp)) != EOF && c != '\n')
235+
{
236+
; /* drain remainder of overlong line */
237+
}
238+
continue;
239+
}
240+
225241
// Skip comments
226242
while (isspace(*line))
227243
{

0 commit comments

Comments
 (0)