fix intrctl_io_firstline() to properly return NULL if there are no records

to show
This commit is contained in:
jdolecek 2018-06-23 11:11:00 +00:00
parent 908b4d8725
commit 5dfdf5bea8
1 changed files with 10 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: intrctl_io.c,v 1.3 2016/08/05 06:58:55 knakahara Exp $ */
/* $NetBSD: intrctl_io.c,v 1.4 2018/06/23 11:11:00 jdolecek Exp $ */
/*
* Copyright (c) 2015 Internet Initiative Japan Inc.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: intrctl_io.c,v 1.3 2016/08/05 06:58:55 knakahara Exp $");
__RCSID("$NetBSD: intrctl_io.c,v 1.4 2018/06/23 11:11:00 jdolecek Exp $");
#include <sys/sysctl.h>
#include <sys/intrio.h>
@ -108,8 +108,15 @@ struct intrio_list_line *
intrctl_io_firstline(void *handle)
{
struct intrio_list *list = handle;
struct intrio_list_line *next;
char *buf_end;
return (struct intrio_list_line *)((char *)list + list->il_lineoffset);
buf_end = (char *)list + list->il_bufsize;
next = (struct intrio_list_line *)((char *)list + list->il_lineoffset);
if ((char *)next >= buf_end)
return NULL;
return next;
}
struct intrio_list_line *