1
1

libssh2_knownhost_del: fix write to freed memory.

When removing a known host, libssh2_knownhost_del would remove the node from the linked list, free its memory and then overwrite the struct parameter (which indicated which node to remove) with 0.  However, this struct is actually allocated within the just-freed node meaning we're writing to freed memory.  This made Windows very upset.

The fix is simply to overwrite the struct first before freeing the memory.
Этот коммит содержится в:
Alexander Lamaison 2010-02-22 14:50:08 +00:00
родитель b4f12e153a
Коммит 3e1a95392e

Просмотреть файл

@ -354,12 +354,13 @@ libssh2_knownhost_del(LIBSSH2_KNOWNHOSTS *hosts,
/* unlink from the list of all hosts */
_libssh2_list_remove(&node->node);
/* clear the struct now since the memory in which it is allocated is
about to be freed! */
memset(entry, 0, sizeof(struct libssh2_knownhost));
/* free all resources */
free_host(hosts->session, node);
/* clear the struct now since this host entry has been removed! */
memset(entry, 0, sizeof(struct libssh2_knownhost));
return 0;
}