Guard NULL property matches and harden name_match

This commit is contained in:
Mario Fetka
2026-04-20 23:39:42 +02:00
parent 5feaf88b2b
commit ae20893723
2 changed files with 5 additions and 2 deletions

View File

@@ -368,14 +368,14 @@ static int loc_delete_property(uint32 obj_id,
int result = -0xfb; /* no property */
memset(xset, 0, sizeof(xset));
if (!prop_id) {
XDPRINTF((2,0, "loc_delete_property obj_id=0x%x, prop=%s", obj_id, prop_name));
XDPRINTF((2,0, "loc_delete_property obj_id=0x%x, prop=%s", obj_id, prop_name ? (char*)prop_name : "(null)"));
if (!dbminit(FNPROP)){
for (key = firstkey(); key.dptr != NULL; key = nextkey(key)) {
NETPROP *p=(NETPROP*)key.dptr;
if (p->obj_id == obj_id) {
data = fetch(key);
p = (NETPROP*)data.dptr;
if (p != NULL && name_match(p->name, prop_name)){
if (p != NULL && (!prop_name || !*prop_name || name_match(p->name, prop_name))){
XDPRINTF((2,0, "found prop: %s, id=%d for deleting", p->name, (int)p->id));
if (ever || !b_acc(obj_id, p->security, 0x13)) {
if ((int)(p->id) > result) result = (int)(p->id);

View File

@@ -706,6 +706,9 @@ int name_match(uint8 *s, uint8 *p)
/* simple match routine matches '?' and '*' */
{
uint8 pc;
if (!s || !p)
return(0);
while ( (pc = *p++) != 0){
switch (pc) {
case '?' : if (!*s++) return(0); /* simple char */