Author: tuexen
Date: Tue Sep 16 14:20:33 2014
New Revision: 271673
URL: http://svnweb.freebsd.org/changeset/base/271673

Log:
  Use a consistent type for the number of HMAC algorithms.
  This fixes a bug which resulted in a warning on the userland
  stack, when compiled on Windows.
  Thanks to Peter Kasting from Google for reporting the issue and
  provinding a potential fix.
  
  MFC after: 3 days

Modified:
  head/sys/netinet/sctp_auth.c
  head/sys/netinet/sctp_auth.h
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctp_usrreq.c

Modified: head/sys/netinet/sctp_auth.c
==============================================================================
--- head/sys/netinet/sctp_auth.c        Tue Sep 16 13:48:46 2014        
(r271672)
+++ head/sys/netinet/sctp_auth.c        Tue Sep 16 14:20:33 2014        
(r271673)
@@ -631,7 +631,7 @@ sctp_copy_skeylist(const struct sctp_key
 
 
 sctp_hmaclist_t *
-sctp_alloc_hmaclist(uint8_t num_hmacs)
+sctp_alloc_hmaclist(uint16_t num_hmacs)
 {
        sctp_hmaclist_t *new_list;
        int alloc_size;
@@ -1438,8 +1438,8 @@ sctp_auth_get_cookie_params(struct sctp_
                        p_random = (struct sctp_auth_random *)phdr;
                        random_len = plen - sizeof(*p_random);
                } else if (ptype == SCTP_HMAC_LIST) {
-                       int num_hmacs;
-                       int i;
+                       uint16_t num_hmacs;
+                       uint16_t i;
 
                        if (plen > sizeof(hmacs_store))
                                break;

Modified: head/sys/netinet/sctp_auth.h
==============================================================================
--- head/sys/netinet/sctp_auth.h        Tue Sep 16 13:48:46 2014        
(r271672)
+++ head/sys/netinet/sctp_auth.h        Tue Sep 16 14:20:33 2014        
(r271673)
@@ -154,7 +154,7 @@ sctp_auth_key_release(struct sctp_tcb *s
 
 
 /* hmac list handling */
-extern sctp_hmaclist_t *sctp_alloc_hmaclist(uint8_t num_hmacs);
+extern sctp_hmaclist_t *sctp_alloc_hmaclist(uint16_t num_hmacs);
 extern void sctp_free_hmaclist(sctp_hmaclist_t * list);
 extern int sctp_auth_add_hmacid(sctp_hmaclist_t * list, uint16_t hmac_id);
 extern sctp_hmaclist_t *sctp_copy_hmaclist(sctp_hmaclist_t * list);

Modified: head/sys/netinet/sctp_pcb.c
==============================================================================
--- head/sys/netinet/sctp_pcb.c Tue Sep 16 13:48:46 2014        (r271672)
+++ head/sys/netinet/sctp_pcb.c Tue Sep 16 14:20:33 2014        (r271673)
@@ -6509,8 +6509,8 @@ sctp_load_addresses_from_init(struct sct
                        }
                        got_random = 1;
                } else if (ptype == SCTP_HMAC_LIST) {
-                       int num_hmacs;
-                       int i;
+                       uint16_t num_hmacs;
+                       uint16_t i;
 
                        if (plen > sizeof(hmacs_store))
                                break;

Modified: head/sys/netinet/sctp_usrreq.c
==============================================================================
--- head/sys/netinet/sctp_usrreq.c      Tue Sep 16 13:48:46 2014        
(r271672)
+++ head/sys/netinet/sctp_usrreq.c      Tue Sep 16 14:20:33 2014        
(r271673)
@@ -4208,12 +4208,13 @@ sctp_setopt(struct socket *so, int optna
                        uint32_t i;
 
                        SCTP_CHECK_AND_CAST(shmac, optval, struct 
sctp_hmacalgo, optsize);
-                       if (optsize < sizeof(struct sctp_hmacalgo) + 
shmac->shmac_number_of_idents * sizeof(uint16_t)) {
+                       if ((optsize < sizeof(struct sctp_hmacalgo) + 
shmac->shmac_number_of_idents * sizeof(uint16_t)) ||
+                           (shmac->shmac_number_of_idents > 0xffff)) {
                                SCTP_LTRACE_ERR_RET(inp, NULL, NULL, 
SCTP_FROM_SCTP_USRREQ, EINVAL);
                                error = EINVAL;
                                break;
                        }
-                       hmaclist = 
sctp_alloc_hmaclist(shmac->shmac_number_of_idents);
+                       hmaclist = sctp_alloc_hmaclist((uint16_t) 
shmac->shmac_number_of_idents);
                        if (hmaclist == NULL) {
                                SCTP_LTRACE_ERR_RET(inp, NULL, NULL, 
SCTP_FROM_SCTP_USRREQ, ENOMEM);
                                error = ENOMEM;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to