mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-06 22:35:46 +00:00
8c08a99745
https://bugzilla.redhat.com/show_bug.cgi?id=1686927 When trying to create a nwfilter binding via nwfilterBindingCreateXML() we may encounter a crash. The sequence of functions called is as follows: 1) nwfilterBindingCreateXML() parses the XML and calls virNWFilterBindingObjListAdd() which calls virNWFilterBindingObjListAddLocked() 2) Here, @binding is not found because binding->remove is set. 3) Therefore, controls continue with creating new @binding, setting its def to the one from 1) and adding it to the hash table. 4) This fails, because the binding is still in the hash table (duplicate key is detected). 5) The control jumps to 'error' label where virNWFilterBindingObjEndAPI() is called which frees the binding definition passed. 6) Error is propagated to the caller, which calls virNWFilterBindingDefFree() over the definition again. The solution is to unset binding->def in case of failure so it's not freed in step 5). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
74 lines
2.2 KiB
C
74 lines
2.2 KiB
C
/*
|
|
* virnwfilterbindingobj.h: network filter binding object processing
|
|
*
|
|
* Copyright (C) 2018 Red Hat, Inc.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library. If not, see
|
|
* <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
#ifndef LIBVIRT_VIRNWFILTERBINDINGOBJ_H
|
|
# define LIBVIRT_VIRNWFILTERBINDINGOBJ_H
|
|
|
|
# include "internal.h"
|
|
# include "virnwfilterbindingdef.h"
|
|
# include "virobject.h"
|
|
|
|
typedef struct _virNWFilterBindingObj virNWFilterBindingObj;
|
|
typedef virNWFilterBindingObj *virNWFilterBindingObjPtr;
|
|
|
|
virNWFilterBindingObjPtr
|
|
virNWFilterBindingObjNew(void);
|
|
|
|
virNWFilterBindingDefPtr
|
|
virNWFilterBindingObjGetDef(virNWFilterBindingObjPtr obj);
|
|
|
|
void
|
|
virNWFilterBindingObjSetDef(virNWFilterBindingObjPtr obj,
|
|
virNWFilterBindingDefPtr def);
|
|
|
|
virNWFilterBindingDefPtr
|
|
virNWFilterBindingObjStealDef(virNWFilterBindingObjPtr obj);
|
|
|
|
bool
|
|
virNWFilterBindingObjGetRemoving(virNWFilterBindingObjPtr obj);
|
|
|
|
void
|
|
virNWFilterBindingObjSetRemoving(virNWFilterBindingObjPtr obj,
|
|
bool removing);
|
|
|
|
void
|
|
virNWFilterBindingObjEndAPI(virNWFilterBindingObjPtr *obj);
|
|
|
|
char *
|
|
virNWFilterBindingObjConfigFile(const char *dir,
|
|
const char *name);
|
|
|
|
int
|
|
virNWFilterBindingObjSave(const virNWFilterBindingObj *obj,
|
|
const char *statusDir);
|
|
|
|
int
|
|
virNWFilterBindingObjDelete(const virNWFilterBindingObj *obj,
|
|
const char *statusDir);
|
|
|
|
virNWFilterBindingObjPtr
|
|
virNWFilterBindingObjParseFile(const char *filename);
|
|
|
|
char *
|
|
virNWFilterBindingObjFormat(const virNWFilterBindingObj *obj);
|
|
|
|
#endif /* LIBVIRT_VIRNWFILTERBINDINGOBJ_H */
|