[asterisk-commits] russell: branch group/security_events r201820 - /team/group/security_events/m...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 18 16:36:56 CDT 2009


Author: russell
Date: Thu Jun 18 16:36:52 2009
New Revision: 201820

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=201820
Log:
Don't use ast_str when it's overkill

Modified:
    team/group/security_events/main/manager.c

Modified: team/group/security_events/main/manager.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/main/manager.c?view=diff&rev=201820&r1=201819&r2=201820
==============================================================================
--- team/group/security_events/main/manager.c (original)
+++ team/group/security_events/main/manager.c Thu Jun 18 16:36:52 2009
@@ -1755,7 +1755,7 @@
 static void report_invalid_user(const struct mansession *s, const char *username)
 {
 	struct sockaddr_in sin_local;
-	struct ast_str *session_id = ast_str_alloca(32);
+	char session_id[32];
 	struct ast_security_event_inval_acct_id inval_acct_id = {
 		.common.event_type = AST_SECURITY_EVENT_INVAL_ACCT_ID,
 		.common.version    = AST_SECURITY_EVENT_INVAL_ACCT_ID_VERSION,
@@ -1770,10 +1770,10 @@
 			.sin       = &s->session->sin,
 			.transport = mansession_get_transport(s),
 		},
+		.common.session_id = session_id,
 	};
 
-	ast_str_set(&session_id, 0, "%p", s->session);
-	inval_acct_id.common.session_id = ast_str_buffer(session_id);
+	snprintf(session_id, sizeof(session_id), "%p", s);
 
 	ast_security_event_report(AST_SEC_EVT(&inval_acct_id));
 }
@@ -1781,7 +1781,7 @@
 static void report_failed_acl(const struct mansession *s, const char *username)
 {
 	struct sockaddr_in sin_local;
-	struct ast_str *session_id = ast_str_alloca(32);
+	char session_id[32];
 	struct ast_security_event_failed_acl failed_acl_event = {
 		.common.event_type = AST_SECURITY_EVENT_FAILED_ACL,
 		.common.version    = AST_SECURITY_EVENT_FAILED_ACL_VERSION,
@@ -1796,10 +1796,10 @@
 			.sin       = &s->session->sin,
 			.transport = mansession_get_transport(s),
 		},
+		.common.session_id = session_id,
 	};
 
-	ast_str_set(&session_id, 0, "%p", s->session);
-	failed_acl_event.common.session_id = ast_str_buffer(session_id);
+	snprintf(session_id, sizeof(session_id), "%p", s->session);
 
 	ast_security_event_report(AST_SEC_EVT(&failed_acl_event));
 }
@@ -1807,7 +1807,7 @@
 static void report_inval_password(const struct mansession *s, const char *username)
 {
 	struct sockaddr_in sin_local;
-	struct ast_str *session_id = ast_str_alloca(32);
+	char session_id[32];
 	struct ast_security_event_inval_password inval_password = {
 		.common.event_type = AST_SECURITY_EVENT_INVAL_PASSWORD,
 		.common.version    = AST_SECURITY_EVENT_INVAL_PASSWORD_VERSION,
@@ -1822,10 +1822,10 @@
 			.sin       = &s->session->sin,
 			.transport = mansession_get_transport(s),
 		},
+		.common.session_id = session_id,
 	};
 
-	ast_str_set(&session_id, 0, "%p", s->session);
-	inval_password.common.session_id = ast_str_buffer(session_id);
+	snprintf(session_id, sizeof(session_id), "%p", s->session);
 
 	ast_security_event_report(AST_SEC_EVT(&inval_password));
 }
@@ -1833,7 +1833,7 @@
 static void report_auth_success(const struct mansession *s)
 {
 	struct sockaddr_in sin_local;
-	struct ast_str *session_id = ast_str_alloca(32);
+	char session_id[32];
 	struct ast_security_event_successful_auth successful_auth = {
 		.common.event_type = AST_SECURITY_EVENT_SUCCESSFUL_AUTH,
 		.common.version    = AST_SECURITY_EVENT_SUCCESSFUL_AUTH_VERSION,
@@ -1848,10 +1848,10 @@
 			.sin       = &s->session->sin,
 			.transport = mansession_get_transport(s),
 		},
+		.common.session_id = session_id,
 	};
 
-	ast_str_set(&session_id, 0, "%p", s->session);
-	successful_auth.common.session_id = ast_str_buffer(session_id);
+	snprintf(session_id, sizeof(session_id), "%p", s->session);
 
 	ast_security_event_report(AST_SEC_EVT(&successful_auth));
 }
@@ -1859,8 +1859,8 @@
 static void report_req_not_allowed(const struct mansession *s, const char *action)
 {
 	struct sockaddr_in sin_local;
-	struct ast_str *session_id = ast_str_alloca(32);
-	struct ast_str *request_type = ast_str_alloca(64);
+	char session_id[32];
+	char request_type[64];
 	struct ast_security_event_req_not_allowed req_not_allowed = {
 		.common.event_type = AST_SECURITY_EVENT_REQ_NOT_ALLOWED,
 		.common.version    = AST_SECURITY_EVENT_REQ_NOT_ALLOWED_VERSION,
@@ -1875,13 +1875,13 @@
 			.sin       = &s->session->sin,
 			.transport = mansession_get_transport(s),
 		},
+		.common.session_id = session_id,
+
+		.request_type      = request_type,
 	};
 
-	ast_str_set(&session_id, 0, "%p", s->session);
-	req_not_allowed.common.session_id = ast_str_buffer(session_id);
-
-	ast_str_set(&request_type, 0, "Action: %s", action);
-	req_not_allowed.request_type = ast_str_buffer(request_type);
+	snprintf(session_id, sizeof(session_id), "%p", s->session);
+	snprintf(request_type, sizeof(request_type), "Action: %s", action);
 
 	ast_security_event_report(AST_SEC_EVT(&req_not_allowed));
 }
@@ -1889,8 +1889,8 @@
 static void report_req_bad_format(const struct mansession *s, const char *action)
 {
 	struct sockaddr_in sin_local;
-	struct ast_str *session_id = ast_str_alloca(32);
-	struct ast_str *request_type = ast_str_alloca(64);
+	char session_id[32];
+	char request_type[64];
 	struct ast_security_event_req_bad_format req_bad_format = {
 		.common.event_type = AST_SECURITY_EVENT_REQ_BAD_FORMAT,
 		.common.version    = AST_SECURITY_EVENT_REQ_BAD_FORMAT_VERSION,
@@ -1905,13 +1905,13 @@
 			.sin       = &s->session->sin,
 			.transport = mansession_get_transport(s),
 		},
+		.common.session_id = session_id,
+
+		.request_type      = request_type,
 	};
 
-	ast_str_set(&session_id, 0, "%p", s->session);
-	req_bad_format.common.session_id = ast_str_buffer(session_id);
-
-	ast_str_set(&request_type, 0, "Action: %s", action);
-	req_bad_format.request_type = ast_str_buffer(request_type);
+	snprintf(session_id, sizeof(session_id), "%p", s->session);
+	snprintf(request_type, sizeof(request_type), "Action: %s", action);
 
 	ast_security_event_report(AST_SEC_EVT(&req_bad_format));
 }
@@ -1920,7 +1920,7 @@
 		const char *response, const char *expected_response)
 {
 	struct sockaddr_in sin_local;
-	struct ast_str *session_id = ast_str_alloca(32);
+	char session_id[32];
 	struct ast_security_event_chal_resp_failed chal_resp_failed = {
 		.common.event_type = AST_SECURITY_EVENT_CHAL_RESP_FAILED,
 		.common.version    = AST_SECURITY_EVENT_CHAL_RESP_FAILED_VERSION,
@@ -1935,13 +1935,14 @@
 			.sin       = &s->session->sin,
 			.transport = mansession_get_transport(s),
 		},
+		.common.session_id = session_id,
+
 		.challenge         = s->session->challenge,
 		.response          = response,
 		.expected_response = expected_response,
 	};
 
-	ast_str_set(&session_id, 0, "%p", s->session);
-	chal_resp_failed.common.session_id = ast_str_buffer(session_id);
+	snprintf(session_id, sizeof(session_id), "%p", s->session);
 
 	ast_security_event_report(AST_SEC_EVT(&chal_resp_failed));
 }
@@ -1949,7 +1950,7 @@
 static void report_session_limit(const struct mansession *s)
 {
 	struct sockaddr_in sin_local;
-	struct ast_str *session_id = ast_str_alloca(32);
+	char session_id[32];
 	struct ast_security_event_session_limit session_limit = {
 		.common.event_type = AST_SECURITY_EVENT_SESSION_LIMIT,
 		.common.version    = AST_SECURITY_EVENT_SESSION_LIMIT_VERSION,
@@ -1964,10 +1965,10 @@
 			.sin       = &s->session->sin,
 			.transport = mansession_get_transport(s),
 		},
+		.common.session_id = session_id,
 	};
 
-	ast_str_set(&session_id, 0, "%p", s->session);
-	session_limit.common.session_id = ast_str_buffer(session_id);
+	snprintf(session_id, sizeof(session_id), "%p", s->session);
 
 	ast_security_event_report(AST_SEC_EVT(&session_limit));
 }




More information about the asterisk-commits mailing list