nwbind: escape bindery object names in debug logs
All checks were successful
Source release / source-package (push) Successful in 48s

Bindery object names are fixed-size NetWare protocol fields and may contain
non-printable bytes when they originate from SAP service advertisements.

Use the existing bounded printable formatter for bindery object names in debug
output so nwbind logs do not emit raw high-bit/control bytes for SAP-derived
objects.  This keeps diagnostics readable after SAP name logging was made
bounded in nwserv.

This is logging-only and does not change bindery or SAP/RIP behavior.
This commit is contained in:
Mario Fetka
2026-05-29 22:10:00 +02:00
parent 44a309de40
commit 4bbec93f4f

View File

@@ -250,7 +250,7 @@ static int handle_iobj(int mode, NETOBJ *o)
if (data.dptr != NULL) {
NETIOBJ *piobj=(NETIOBJ*)data.dptr;
XDPRINTF((3,0, "got index of OBJ name=%s, type=0x%x, id = 0x%x",
piobj->name, (int)piobj->type, piobj->id));
visable_data(piobj->name, sizeof(piobj->name)), (int)piobj->type, piobj->id));
if (!mode) {
o->id = piobj->id;
result = 0;
@@ -269,7 +269,7 @@ static int handle_iobj(int mode, NETOBJ *o)
dbmclose();
XDPRINTF((3, 0,"handle_iobj mode=%d, result=0x%x, OBJ=%s, type=0x%x",
mode, -result,
o->name,(int)o->type));
visable_data(o->name, sizeof(o->name)),(int)o->type));
return(result);
}
@@ -277,7 +277,7 @@ int find_obj_id(NETOBJ *o)
/* no wildcards allowed */
{
int result;
XDPRINTF((2, 0,"findobj_id OBJ=%s, type=0x%x", o->name,(int)o->type));
XDPRINTF((2, 0,"findobj_id OBJ=%s, type=0x%x", visable_data(o->name, sizeof(o->name)),(int)o->type));
if ((result=handle_iobj(0, o)) == 0) {
result = -0xff;
if (!dbminit(FNOBJ)){
@@ -286,19 +286,19 @@ int find_obj_id(NETOBJ *o)
data = fetch(key);
if (data.dptr != NULL){
NETOBJ *obj=(NETOBJ*)data.dptr;
XDPRINTF((3,0, "got OBJ name=%s, id = 0x%x", obj->name, (int)obj->id));
XDPRINTF((3,0, "got OBJ name=%s, id = 0x%x", visable_data(obj->name, sizeof(obj->name)), (int)obj->id));
if ( (!strncmp(obj->name, o->name, sizeof(obj->name)))
&& obj->type == o->type) {
memcpy(o, data.dptr, sizeof(NETOBJ));
result=0;
} else {
XDPRINTF((1,0, "OBJ Index '%s',0x%x, clashes OBJ data '%s', 0x%x",
o->name, (int)o->type,
obj->name, (int)obj->type));
visable_data(o->name, sizeof(o->name)), (int)o->type,
visable_data(obj->name, sizeof(obj->name)), (int)obj->type));
}
} else {
XDPRINTF((1,0, "OBJ Index '%s',0x%x, id=0x%x not found in OBJ data",
o->name, (int)o->type, o->id));
visable_data(o->name, sizeof(o->name)), (int)o->type, o->id));
}
}
dbmclose();
@@ -308,7 +308,7 @@ int find_obj_id(NETOBJ *o)
result=scan_for_obj(o, 0, 1);
if (!result) { /* was ok, we will rewrite/creat iobj record */
XDPRINTF((1, 0,"findobj_id OBJ='%s', type=0x%x, id=0x%x not in Index File",
o->name,(int)o->type,o->id));
visable_data(o->name, sizeof(o->name)),(int)o->type,o->id));
handle_iobj(2, o);
}
return(result);
@@ -323,7 +323,7 @@ int scan_for_obj(NETOBJ *o, uint32 last_obj_id, int ignore_rights)
{
int result = -0xfc; /* no Object */
XDPRINTF((2, 0,"scan_for_obj OBJ=%s, type=0x%x, lastid=0x%x",
o->name, (int)o->type, (int)last_obj_id));
visable_data(o->name, sizeof(o->name)), (int)o->type, (int)last_obj_id));
if (!dbminit(FNOBJ)){
key = firstkey();
@@ -342,12 +342,12 @@ int scan_for_obj(NETOBJ *o, uint32 last_obj_id, int ignore_rights)
name_match(obj->name, o->name) &&
( ignore_rights ||
(b_acc(obj->id, obj->security, 0x00)== 0))) {
XDPRINTF((2, 0, "found OBJ=%s, id=0x%x", obj->name, (int)obj->id));
XDPRINTF((2, 0, "found OBJ=%s, id=0x%x", visable_data(obj->name, sizeof(obj->name)), (int)obj->id));
result = 0;
memcpy((char *)o, (char*)obj, sizeof(NETOBJ));
} else {
XDPRINTF((3,0,"not found,but NAME=%s, type=0x%x, id=0x%x",
obj->name, (int)obj->type, (int)obj->id));
visable_data(obj->name, sizeof(obj->name)), (int)obj->type, (int)obj->id));
}
}
if (result) key = nextkey(key);
@@ -539,7 +539,7 @@ static int loc_delete_obj(uint32 objid, int security)
int nw_delete_obj(NETOBJ *obj)
{
int result = find_obj_id(obj);
XDPRINTF((2,0, "nw_delete_obj obj_id=%d, obj_name=%s", obj->id, obj->name));
XDPRINTF((2,0, "nw_delete_obj obj_id=%d, obj_name=%s", obj->id, visable_data(obj->name, sizeof(obj->name))));
if (!result)
result=loc_delete_obj(obj->id, obj->security);
return(result);
@@ -560,7 +560,7 @@ int nw_rename_obj(NETOBJ *o, uint8 *newname)
data = fetch(key);
if (data.dptr != NULL){
NETOBJ *obj=(NETOBJ*)data.dptr;
XDPRINTF((2,0, "rename_obj:got OBJ name=%s, id = 0x%x", obj->name, (int)obj->id));
XDPRINTF((2,0, "rename_obj:got OBJ name=%s, id = 0x%x", visable_data(obj->name, sizeof(obj->name)), (int)obj->id));
memset(obj->name, 0, sizeof(obj->name));
strncpy((char*)obj->name, (char*)newname, sizeof(obj->name)-1);
obj->name[sizeof(obj->name)-1] = '\0';
@@ -590,7 +590,7 @@ int nw_change_obj_security(NETOBJ *o, int newsecurity)
data = fetch(key);
if (data.dptr != NULL){
NETOBJ *obj=(NETOBJ*)data.dptr;
XDPRINTF((2,0, "change_obj_security:got OBJ name=%s, id = 0x%x", obj->name, (int)obj->id));
XDPRINTF((2,0, "change_obj_security:got OBJ name=%s, id = 0x%x", visable_data(obj->name, sizeof(obj->name)), (int)obj->id));
obj->security = (uint8) newsecurity;
if (!store(key, data)) result=0;
}
@@ -610,7 +610,7 @@ int nw_get_obj(NETOBJ *o)
if (data.dptr != NULL){
NETOBJ *obj=(NETOBJ*)data.dptr;
result = b_acc(o->id, obj->security, 0x0);
XDPRINTF((2,0, "got OBJ name=%s, id = 0x%x", obj->name, (int)obj->id));
XDPRINTF((2,0, "got OBJ name=%s, id = 0x%x", visable_data(obj->name, sizeof(obj->name)), (int)obj->id));
if (!result) memcpy(o, data.dptr, sizeof(NETOBJ));
}
} else result = -0xff;
@@ -894,7 +894,7 @@ int nw_delete_property(int object_type,
strmaxcpy((char*)obj.name, (char*)object_name, object_namlen);
strmaxcpy((char*)prop_name_x, (char*)prop_name, prop_namlen);
XDPRINTF((2,0, "nw_delete_property obj=%s, prop=%s, type=0x%x",
obj.name, prop_name_x, object_type));
visable_data(obj.name, sizeof(obj.name)), prop_name_x, object_type));
obj.type = (uint16) object_type;
if ((result = find_obj_id(&obj)) == 0){
result = loc_delete_property(obj.id, prop_name_x, 0, 0);
@@ -927,7 +927,8 @@ int nw_is_obj_in_set(int object_type,
strmaxcpy((char*)mobj.name, (char*)member_name, member_namlen);
strmaxcpy((char*)prop.name, (char*)prop_name, prop_namlen);
XDPRINTF((2,0, "nw_is_obj_in_set obj=%s,0x%x, member=%s,0x%x, prop=%s",
obj.name, object_type, mobj.name, member_type, prop.name));
visable_data(obj.name, sizeof(obj.name)), object_type,
visable_data(mobj.name, sizeof(mobj.name)), member_type, prop.name));
obj.type = (uint16) object_type;
mobj.type = (uint16) member_type;
if ((result = find_obj_id(&obj)) == 0){
@@ -954,7 +955,8 @@ int nw_add_obj_to_set(int object_type,
strmaxcpy((char*)mobj.name, (char*)member_name, member_namlen);
strmaxcpy((char*)prop.name, (char*)prop_name, prop_namlen);
XDPRINTF((2,0, "nw_add_obj_to_set obj=%s,0x%x, member=%s,0x%x, prop=%s",
obj.name, object_type, mobj.name, member_type, prop.name));
visable_data(obj.name, sizeof(obj.name)), object_type,
visable_data(mobj.name, sizeof(mobj.name)), member_type, prop.name));
obj.type = (uint16) object_type;
mobj.type = (uint16) member_type;
if ((result = find_obj_id(&obj)) == 0){
@@ -985,7 +987,8 @@ int nw_delete_obj_from_set(int object_type,
strmaxcpy((char*)mobj.name, (char*)member_name, member_namlen);
strmaxcpy((char*)prop.name, (char*)prop_name, prop_namlen);
XDPRINTF((2,0, "nw_delete_obj_from_set obj=%s,0x%x, member=%s,0x%x, prop=%s",
obj.name, object_type, mobj.name, member_type, prop.name));
visable_data(obj.name, sizeof(obj.name)), object_type,
visable_data(mobj.name, sizeof(mobj.name)), member_type, prop.name));
obj.type = (uint16) object_type;
mobj.type = (uint16) member_type;
if ((result = find_obj_id(&obj)) == 0){
@@ -1086,7 +1089,7 @@ int nw_list_obj_relations(int object_type,
obj.type = (uint16)object_type;
XDPRINTF((2,0, "nw_list_obj_relations obj=%s,0x%x, prop=%s, last=0x%x",
obj.name, object_type, prop.name, last_seen));
visable_data(obj.name, sizeof(obj.name)), object_type, prop.name, last_seen));
if ((result = find_obj_id(&obj)) == 0) {
result = find_first_prop_id(&prop, obj.id);
@@ -1114,7 +1117,7 @@ int nw_write_prop_value(int object_type,
strmaxcpy((char*)obj.name, (char*)object_name, object_namlen);
strmaxcpy((char*)prop.name, (char*)prop_name, prop_namlen);
XDPRINTF((2,0, "nw_write_prop_value obj=%s, prop=%s, type=0x%x, segment=%d",
obj.name, prop.name, object_type, segment_nr));
visable_data(obj.name, sizeof(obj.name)), prop.name, object_type, segment_nr));
obj.type = (uint16) object_type;
if ((result = find_obj_id(&obj)) == 0){
@@ -1140,7 +1143,7 @@ int nw_change_prop_security(int object_type,
strmaxcpy((char*)prop.name, (char*)prop_name, prop_namlen);
prop.security = (uint8)prop_security;
XDPRINTF((2,0, "nw_change_prop_security obj=%s,0x%x, prop=%s",
obj.name, object_type, prop.name));
visable_data(obj.name, sizeof(obj.name)), object_type, prop.name));
obj.type = (uint16) object_type;
if ((result = find_obj_id(&obj)) == 0)
return(loc_change_prop_security(&prop, obj.id));
@@ -1160,7 +1163,7 @@ int nw_scan_property(NETPROP *prop,
strmaxcpy((char*)obj.name, (char*)object_name, object_namlen);
strmaxcpy((char*)prop->name, (char*)prop_name, prop_namlen);
XDPRINTF((2,0, "nw_scan_property obj=%s, prop=%s, type=0x%x, last_scan=0x%x",
obj.name, prop->name, object_type, (int)*last_scan));
visable_data(obj.name, sizeof(obj.name)), prop->name, object_type, (int)*last_scan));
obj.type = (uint16) object_type;
if ((result = find_obj_id(&obj)) == 0){
@@ -1206,7 +1209,7 @@ int nw_create_obj(NETOBJ *obj, uint32 wanted_id)
*/
{
int result = b_acc(0, 0x33, 0x02);
XDPRINTF((2,0, "creat OBJ=%s,type=0x%x", obj->name, (int)obj->type));
XDPRINTF((2,0, "creat OBJ=%s,type=0x%x", visable_data(obj->name, sizeof(obj->name)), (int)obj->type));
if (result) return(result); /* no object creat rights */
if (!dbminit(FNOBJ)){
for (key = firstkey(); key.dptr != NULL; key = nextkey(key)) {
@@ -1328,7 +1331,7 @@ int nw_create_prop(int object_type,
result = nw_create_obj_prop(obj.id, &prop);
}
XDPRINTF((2,0, "nw_create_prop obj=%s, prop=%s, type=0x%x, result=0x%x",
obj.name, prop.name, object_type, result));
visable_data(obj.name, sizeof(obj.name)), prop.name, object_type, result));
return(result);
}
@@ -1941,7 +1944,7 @@ static void add_pr_server(uint32 ps_id,
strmaxcpy((char*)obj.name, (char*)ps_name, 47);
obj.type = 0x1; /* USER */
if (find_obj_id(&obj)) {
XDPRINTF((1, 0, "add_pr_server:user=%s not exist", obj.name));
XDPRINTF((1, 0, "add_pr_server:user=%s not exist", visable_data(obj.name, sizeof(obj.name))));
return;
}
ps_id=obj.id;