Module Name:    src
Committed By:   skrll
Date:           Sun Oct 13 07:46:26 UTC 2013

Modified Files:
        src/sys/external/bsd/vchiq/dist/interface/vchiq_arm: vchiq_arm.c
            vchiq_core.c

Log Message:
Print the client_id (lwp address) as hex and avoid stack overflow. Use
snprintf while here.

Fixes PR/48287


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
    src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
cvs rdiff -u -r1.5 -r1.6 \
    src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.6 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.7
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c:1.6	Thu Sep 19 15:13:43 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c	Sun Oct 13 07:46:26 2013
@@ -577,7 +577,7 @@ vchiq_ioctl(struct file *fp, u_long cmd,
 			if (status != VCHIQ_SUCCESS) {
 				vchiq_log_error(vchiq_susp_log_level,
 					"%s: cmd %s returned error %d for "
-					"service %c%c%c%c:%03d",
+					"service %c%c%c%c:%8x",
 					__func__,
 					(cmd == VCHIQ_IOC_USE_SERVICE) ?
 						"VCHIQ_IOC_USE_SERVICE" :
@@ -1942,7 +1942,7 @@ output_timeout_error(VCHIQ_STATE_T *stat
 		VCHIQ_SERVICE_T *service_ptr = state->services[i];
 		if (service_ptr && service_ptr->service_use_count &&
 			(service_ptr->srvstate != VCHIQ_SRVSTATE_FREE)) {
-			snprintf(service_err, 50, " %c%c%c%c(%d) service has "
+			snprintf(service_err, 50, " %c%c%c%c(%8x) service has "
 				"use count %d%s", VCHIQ_FOURCC_AS_4CHARS(
 					service_ptr->base.fourcc),
 				 service_ptr->client_id,
@@ -2237,7 +2237,7 @@ vchiq_use_internal(VCHIQ_STATE_T *state,
 		sprintf(entity, "VCHIQ:   ");
 		entity_uc = &arm_state->peer_use_count;
 	} else if (service) {
-		sprintf(entity, "%c%c%c%c:%03d",
+		snprintf(entity, sizeof(entity), "%c%c%c%c:%8x",
 			VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc),
 			service->client_id);
 		entity_uc = &service->service_use_count;
@@ -2366,7 +2366,7 @@ vchiq_release_internal(VCHIQ_STATE_T *st
 	vchiq_log_trace(vchiq_susp_log_level, "%s", __func__);
 
 	if (service) {
-		sprintf(entity, "%c%c%c%c:%03d",
+		snprintf(entity, sizeof(entity), "%c%c%c%c:%8x",
 			VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc),
 			service->client_id);
 		entity_uc = &service->service_use_count;
@@ -2596,7 +2596,7 @@ vchiq_check_service(VCHIQ_SERVICE_T *ser
 
 	if (ret == VCHIQ_ERROR) {
 		vchiq_log_error(vchiq_susp_log_level,
-			"%s ERROR - %c%c%c%c:%d service count %d, "
+			"%s ERROR - %c%c%c%c:%8x service count %d, "
 			"state count %d, videocore suspend state %s", __func__,
 			VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc),
 			service->client_id, service->service_use_count,

Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.5 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.6
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c:1.5	Fri Sep 20 09:05:53 2013
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_core.c	Sun Oct 13 07:46:26 2013
@@ -3664,7 +3664,7 @@ vchiq_dump_service_state(void *dump_cont
 			if (service->public_fourcc != VCHIQ_FOURCC_INVALID)
 				snprintf(remoteport + len2,
 					sizeof(remoteport) - len2,
-					" (client %x)", service->client_id);
+					" (client %8x)", service->client_id);
 		} else
 			strcpy(remoteport, "n/a");
 

Reply via email to