Fix buffer overflow if NULL line is present in db.

If ptr->line == NULL for an entry, the first cycle will exit,
but the second one will happily write past entries buffer.
We actually do not want to exit the first cycle prematurely
on ptr->line == NULL.
Signed-off-by: Tomas Mraz <tmraz@fedoraproject.org>
This commit is contained in:
Tomas Mraz 2017-03-31 16:25:06 +02:00
parent 830ae266c4
commit 954e3d2e71

View File

@ -751,16 +751,16 @@ commonio_sort (struct commonio_db *db, int (*cmp) (const void *, const void *))
for (ptr = db->head; for (ptr = db->head;
(NULL != ptr) (NULL != ptr)
#if KEEP_NIS_AT_END #if KEEP_NIS_AT_END
&& (NULL != ptr->line) && ((NULL == ptr->line)
&& ( ('+' != ptr->line[0]) || (('+' != ptr->line[0])
&& ('-' != ptr->line[0])) && ('-' != ptr->line[0])))
#endif #endif
; ;
ptr = ptr->next) { ptr = ptr->next) {
n++; n++;
} }
#if KEEP_NIS_AT_END #if KEEP_NIS_AT_END
if ((NULL != ptr) && (NULL != ptr->line)) { if (NULL != ptr) {
nis = ptr; nis = ptr;
} }
#endif #endif