svn commit: r299808 - head/contrib/bsnmp/snmp_usm

Garrett Cooper ngie at FreeBSD.org
Sun May 15 00:13:38 UTC 2016


Author: ngie
Date: Sun May 15 00:13:36 2016
New Revision: 299808
URL: https://svnweb.freebsd.org/changeset/base/299808

Log:
  Use sizeof(..)s for the destination buffers instead of hardcoded values corresponding
  to the destination buffer sizes
  
  MFC after: 1 week
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/contrib/bsnmp/snmp_usm/usm_snmp.c

Modified: head/contrib/bsnmp/snmp_usm/usm_snmp.c
==============================================================================
--- head/contrib/bsnmp/snmp_usm/usm_snmp.c	Sun May 15 00:10:37 2016	(r299807)
+++ head/contrib/bsnmp/snmp_usm/usm_snmp.c	Sun May 15 00:13:36 2016	(r299808)
@@ -262,7 +262,7 @@ op_usm_users(struct snmp_context *ctx, s
 			if (ctx->scratch->ptr1 == NULL)
 				return (SNMP_ERR_GENERR);
 			memcpy(ctx->scratch->ptr1, uuser->suser.priv_key,
-			    SNMP_PRIV_KEY_SIZ);
+			    sizeof(uuser->suser.priv_key));
 			memcpy(uuser->suser.priv_key, val->v.octetstring.octets,
 			    val->v.octetstring.len);
 			break;
@@ -286,7 +286,7 @@ op_usm_users(struct snmp_context *ctx, s
 				uuser->user_public_len = val->v.octetstring.len;
 			} else {
 				memset(uuser->user_public, 0,
-				    SNMP_ADM_STR32_SIZ);
+				    sizeof(uuser->user_public));
 				uuser->user_public_len = 0;
 			}
 			break;
@@ -351,7 +351,7 @@ op_usm_users(struct snmp_context *ctx, s
 		case LEAF_usmUserAuthKeyChange:
 		case LEAF_usmUserOwnAuthKeyChange:
 			memcpy(uuser->suser.auth_key, ctx->scratch->ptr1,
-			    SNMP_AUTH_KEY_SIZ);
+			    sizeof(uuser->suser.auth_key));
 			free(ctx->scratch->ptr1);
 			break;
 		case LEAF_usmUserPrivProtocol:
@@ -360,7 +360,7 @@ op_usm_users(struct snmp_context *ctx, s
 		case LEAF_usmUserPrivKeyChange:
 		case LEAF_usmUserOwnPrivKeyChange:
 			memcpy(uuser->suser.priv_key, ctx->scratch->ptr1,
-			    SNMP_PRIV_KEY_SIZ);
+			    sizeof(uuser->suser.priv_key));
 			free(ctx->scratch->ptr1);
 			break;
 		case LEAF_usmUserPublic:
@@ -371,7 +371,7 @@ op_usm_users(struct snmp_context *ctx, s
 				free(ctx->scratch->ptr2);
 			} else {
 				memset(uuser->user_public, 0,
-				    SNMP_ADM_STR32_SIZ);
+				    sizeof(uuser->user_public));
 				uuser->user_public_len = 0;
 			}
 			break;


More information about the svn-src-all mailing list