84
84
 
 *
85
85
 
 *              Failure:        Negative
86
86
 
 *
87
87
 
 * Programmer:  Robb Matzke
88
88
 
 *              matzke@llnl.gov
89
89
 
 *              Jul 18 1997
90
90
 
 *
91
91
 
 *-------------------------------------------------------------------------
92
92
 
 */
93
93
 
herr_t
94
 
-
H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, unsigned n)
 
94
+
H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, const uint8_t *p_end,
 
95
+
        H5G_entry_t *ent, unsigned n)
95
96
 
{
96
97
 
    unsigned    u;                      /* Local index variable */
97
98
 
    herr_t      ret_value = SUCCEED;    /* Return value */
98
99
 
99
100
 
    FUNC_ENTER_PACKAGE
100
101
 
101
102
 
    /* check arguments */
102
103
 
    HDassert(f);
103
104
 
    HDassert(pp);
104
105
 
    HDassert(ent);
105
106
 
106
107
 
    /* decode entries */
107
 
-
    for(u = 0; u < n; u++)
 
108
+
    for(u = 0; u < n; u++) {
 
109
+
        if(*pp > p_end)
 
110
+
            HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "ran off the end of the buffer")
108
111
 
        if(H5G_ent_decode(f, pp, ent + u) < 0)
109
112
 
            HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode")
 
113
+
    }
110
114
 
111
115
 
done:
112
116
 
    FUNC_LEAVE_NOAPI(ret_value)
113
117
 
} /* end H5G__ent_decode_vec() */
114
118
 
115
119
 
116
120
 
/*-------------------------------------------------------------------------
117
121
 
 * Function:    H5G_ent_decode
118
122
 
 *
119
123
 
 * Purpose:     Decodes a symbol table entry pointed to by `*pp'.