diff options
author | Hideki Yamane <henrich@debian.org> | 2013-04-11 10:21:36 +0900 |
---|---|---|
committer | Hideki Yamane <henrich@debian.org> | 2013-04-11 10:21:36 +0900 |
commit | 9c3c74a98221880a5804fd58fe541c8b672995d2 (patch) | |
tree | 009bf8fd68af6bb1129e07dd8c1ed205010d81f8 /snmplib/vacm.c | |
parent | e30beeedd5cbe6f72008c32122b3b8b617fd5ab2 (diff) | |
download | pkg-net-snmp-9c3c74a98221880a5804fd58fe541c8b672995d2.tar.gz |
Imported Upstream version 5.7.2~dfsg
Diffstat (limited to 'snmplib/vacm.c')
-rw-r--r-- | snmplib/vacm.c | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/snmplib/vacm.c b/snmplib/vacm.c index 5aa9b82..c639785 100644 --- a/snmplib/vacm.c +++ b/snmplib/vacm.c @@ -31,11 +31,7 @@ #include <sys/types.h> #include <stdio.h> #if TIME_WITH_SYS_TIME -# ifdef WIN32 -# include <sys/timeb.h> -# else -# include <sys/time.h> -# endif +# include <sys/time.h> # include <time.h> #else # if HAVE_SYS_TIME_H @@ -45,10 +41,6 @@ # endif #endif -#if HAVE_WINSOCK_H -#include <winsock.h> -#endif - #if HAVE_NETINET_IN_H #include <netinet/in.h> #endif @@ -62,6 +54,7 @@ #include <net-snmp/config_api.h> #include <net-snmp/library/snmp_api.h> +#include <net-snmp/library/tools.h> #include <net-snmp/library/vacm.h> static struct vacm_viewEntry *viewList = NULL, *viewScanPtr = NULL; @@ -166,7 +159,7 @@ vacm_save_view(struct vacm_viewEntry *view, const char *token, } void -vacm_parse_config_view(const char *token, char *line) +vacm_parse_config_view(const char *token, const char *line) { struct vacm_viewEntry view; struct vacm_viewEntry *vptr; @@ -176,17 +169,17 @@ vacm_parse_config_view(const char *token, char *line) size_t len; view.viewStatus = atoi(line); - line = skip_token(line); + line = skip_token_const(line); view.viewStorageType = atoi(line); - line = skip_token(line); + line = skip_token_const(line); view.viewType = atoi(line); - line = skip_token(line); + line = skip_token_const(line); len = sizeof(view.viewName); line = read_config_read_octet_string(line, (u_char **) & viewName, &len); view.viewSubtreeLen = MAX_OID_LEN; line = - read_config_read_objid(line, (oid **) & viewSubtree, + read_config_read_objid_const(line, (oid **) & viewSubtree, &view.viewSubtreeLen); vptr = @@ -199,10 +192,10 @@ vacm_parse_config_view(const char *token, char *line) vptr->viewStatus = view.viewStatus; vptr->viewStorageType = view.viewStorageType; vptr->viewType = view.viewType; - viewMask = (u_char *) vptr->viewMask; + viewMask = vptr->viewMask; + vptr->viewMaskLen = sizeof(vptr->viewMask); line = - read_config_read_octet_string(line, (u_char **) & viewMask, - &vptr->viewMaskLen); + read_config_read_octet_string(line, &viewMask, &vptr->viewMaskLen); } /* @@ -284,7 +277,8 @@ vacm_save_auth_access(struct vacm_accessEntry *access_entry, } char * -_vacm_parse_config_access_common(struct vacm_accessEntry **aptr, char *line) +_vacm_parse_config_access_common(struct vacm_accessEntry **aptr, + const char *line) { struct vacm_accessEntry access; char *cPrefix = (char *) &access.contextPrefix; @@ -292,15 +286,15 @@ _vacm_parse_config_access_common(struct vacm_accessEntry **aptr, char *line) size_t len; access.status = atoi(line); - line = skip_token(line); + line = skip_token_const(line); access.storageType = atoi(line); - line = skip_token(line); + line = skip_token_const(line); access.securityModel = atoi(line); - line = skip_token(line); + line = skip_token_const(line); access.securityLevel = atoi(line); - line = skip_token(line); + line = skip_token_const(line); access.contextMatch = atoi(line); - line = skip_token(line); + line = skip_token_const(line); len = sizeof(access.groupName); line = read_config_read_octet_string(line, (u_char **) &gName, &len); len = sizeof(access.contextPrefix); @@ -323,11 +317,11 @@ _vacm_parse_config_access_common(struct vacm_accessEntry **aptr, char *line) (*aptr)->securityModel = access.securityModel; (*aptr)->securityLevel = access.securityLevel; (*aptr)->contextMatch = access.contextMatch; - return line; + return NETSNMP_REMOVE_CONST(char *, line); } void -vacm_parse_config_access(const char *token, char *line) +vacm_parse_config_access(const char *token, const char *line) { struct vacm_accessEntry *aptr; char *readView, *writeView, *notifyView; @@ -353,7 +347,7 @@ vacm_parse_config_access(const char *token, char *line) } void -vacm_parse_config_auth_access(const char *token, char *line) +vacm_parse_config_auth_access(const char *token, const char *line) { struct vacm_accessEntry *aptr; int authtype; @@ -365,7 +359,7 @@ vacm_parse_config_auth_access(const char *token, char *line) return; authtype = atoi(line); - line = skip_token(line); + line = skip_token_const(line); view = (char *) aptr->views[authtype]; len = sizeof(aptr->views[authtype]); @@ -401,7 +395,7 @@ vacm_save_group(struct vacm_groupEntry *group_entry, const char *token, } void -vacm_parse_config_group(const char *token, char *line) +vacm_parse_config_group(const char *token, const char *line) { struct vacm_groupEntry group; struct vacm_groupEntry *gptr; @@ -410,11 +404,11 @@ vacm_parse_config_group(const char *token, char *line) size_t len; group.status = atoi(line); - line = skip_token(line); + line = skip_token_const(line); group.storageType = atoi(line); - line = skip_token(line); + line = skip_token_const(line); group.securityModel = atoi(line); - line = skip_token(line); + line = skip_token_const(line); len = sizeof(group.securityName); line = read_config_read_octet_string(line, (u_char **) & securityName, @@ -442,21 +436,21 @@ netsnmp_view_get(struct vacm_viewEntry *head, const char *viewName, int count=0; glen = (int) strlen(viewName); - if (glen < 0 || glen >= VACM_MAX_STRING) + if (glen < 0 || glen > VACM_MAX_STRING) return NULL; view[0] = glen; strcpy(view + 1, viewName); for (vp = head; vp; vp = vp->next) { if (!memcmp(view, vp->viewName, glen + 1) && viewSubtreeLen >= (vp->viewSubtreeLen - 1)) { - int mask = 0x80, maskpos = 0; - int oidpos; + int mask = 0x80; + unsigned int oidpos, maskpos = 0; found = 1; for (oidpos = 0; - found && oidpos < (int) vp->viewSubtreeLen - 1; + found && oidpos < vp->viewSubtreeLen - 1; oidpos++) { - if (mode==VACM_MODE_IGNORE_MASK || (VIEW_MASK(vp, maskpos, mask)) != 0) { + if (mode==VACM_MODE_IGNORE_MASK || (VIEW_MASK(vp, maskpos, mask) != 0)) { if (viewSubtree[oidpos] != vp->viewSubtree[oidpos + 1]) found = 0; @@ -525,7 +519,7 @@ netsnmp_view_subtree_check(struct vacm_viewEntry *head, const char *viewName, int found, glen; glen = (int) strlen(viewName); - if (glen < 0 || glen >= VACM_MAX_STRING) + if (glen < 0 || glen > VACM_MAX_STRING) return VACM_NOTINVIEW; view[0] = glen; strcpy(view + 1, viewName); @@ -538,15 +532,15 @@ netsnmp_view_subtree_check(struct vacm_viewEntry *head, const char *viewName, * subtree we are comparing against. */ if (viewSubtreeLen >= (vp->viewSubtreeLen - 1)) { - int mask = 0x80, maskpos = 0; - int oidpos; + int mask = 0x80; + unsigned int oidpos, maskpos = 0; found = 1; /* * check the mask */ for (oidpos = 0; - found && oidpos < (int) vp->viewSubtreeLen - 1; + found && oidpos < vp->viewSubtreeLen - 1; oidpos++) { if (VIEW_MASK(vp, maskpos, mask) != 0) { if (viewSubtree[oidpos] != @@ -586,15 +580,15 @@ netsnmp_view_subtree_check(struct vacm_viewEntry *head, const char *viewName, * response. */ else { - int mask = 0x80, maskpos = 0; - int oidpos; + int mask = 0x80; + unsigned int oidpos, maskpos = 0; found = 1; /* * check the mask up to the length of the provided subtree */ for (oidpos = 0; - found && oidpos < (int) viewSubtreeLen; + found && oidpos < viewSubtreeLen; oidpos++) { if (VIEW_MASK(vp, maskpos, mask) != 0) { if (viewSubtree[oidpos] != @@ -681,7 +675,7 @@ netsnmp_view_create(struct vacm_viewEntry **head, const char *viewName, int cmp, cmp2, glen; glen = (int) strlen(viewName); - if (glen < 0 || glen >= VACM_MAX_STRING) + if (glen < 0 || glen > VACM_MAX_STRING) return NULL; vp = (struct vacm_viewEntry *) calloc(1, sizeof(struct vacm_viewEntry)); @@ -771,7 +765,7 @@ vacm_getGroupEntry(int securityModel, const char *securityName) int glen; glen = (int) strlen(securityName); - if (glen < 0 || glen >= VACM_MAX_STRING) + if (glen < 0 || glen > VACM_MAX_STRING) return NULL; secname[0] = glen; strcpy(secname + 1, securityName); @@ -807,7 +801,7 @@ vacm_createGroupEntry(int securityModel, const char *securityName) int cmp, glen; glen = (int) strlen(securityName); - if (glen < 0 || glen >= VACM_MAX_STRING) + if (glen < 0 || glen > VACM_MAX_STRING) return NULL; gp = (struct vacm_groupEntry *) calloc(1, sizeof(struct vacm_groupEntry)); @@ -848,6 +842,7 @@ vacm_createGroupEntry(int securityModel, const char *securityName) return gp; } +#ifndef NETSNMP_NO_WRITE_SUPPORT void vacm_destroyGroupEntry(int securityModel, const char *securityName) { @@ -873,6 +868,7 @@ vacm_destroyGroupEntry(int securityModel, const char *securityName) free(vp); return; } +#endif /* NETSNMP_NO_WRITE_SUPPORT */ void vacm_destroyAllGroupEntries(void) @@ -936,10 +932,10 @@ vacm_getAccessEntry(const char *groupName, int glen, clen; glen = (int) strlen(groupName); - if (glen < 0 || glen >= VACM_MAX_STRING) + if (glen < 0 || glen > VACM_MAX_STRING) return NULL; clen = (int) strlen(contextPrefix); - if (clen < 0 || clen >= VACM_MAX_STRING) + if (clen < 0 || clen > VACM_MAX_STRING) return NULL; group[0] = glen; @@ -988,10 +984,10 @@ vacm_createAccessEntry(const char *groupName, int cmp, glen, clen; glen = (int) strlen(groupName); - if (glen < 0 || glen >= VACM_MAX_STRING) + if (glen < 0 || glen > VACM_MAX_STRING) return NULL; clen = (int) strlen(contextPrefix); - if (clen < 0 || clen >= VACM_MAX_STRING) + if (clen < 0 || clen > VACM_MAX_STRING) return NULL; vp = (struct vacm_accessEntry *) calloc(1, sizeof(struct @@ -1044,6 +1040,7 @@ vacm_createAccessEntry(const char *groupName, return vp; } +#ifndef NETSNMP_NO_WRITE_SUPPORT void vacm_destroyAccessEntry(const char *groupName, const char *contextPrefix, @@ -1075,6 +1072,7 @@ vacm_destroyAccessEntry(const char *groupName, free(vp); return; } +#endif /* NETSNMP_NO_WRITE_SUPPORT */ void vacm_destroyAllAccessEntries(void) @@ -1148,12 +1146,14 @@ vacm_createViewEntry(const char *viewName, viewSubtreeLen); } +#ifndef NETSNMP_NO_WRITE_SUPPORT void vacm_destroyViewEntry(const char *viewName, oid * viewSubtree, size_t viewSubtreeLen) { netsnmp_view_destroy( &viewList, viewName, viewSubtree, viewSubtreeLen); } +#endif /* NETSNMP_NO_WRITE_SUPPORT */ void vacm_destroyAllViewEntries(void) |