Changeset 233404 in webkit


Ignore:
Timestamp:
Jun 30, 2018, 6:15:38 PM (7 years ago)
Author:
Michael Catanzaro
Message:

Fix off-by-one error in xdg_mime_get_simple_globs
https://bugs.webkit.org/show_bug.cgi?id=186554

Reviewed by Daniel Bates.

We have an off-by-one error here in some code that was added for WebKit. (This is not an
issue with upstream xdgmime.)

No new tests. This problem is caught by TestDownloads, but only when running with ASan
enabled.

  • xdgmime/src/xdgmimecache.c:

(get_simple_globs):

  • xdgmime/src/xdgmimeglob.c:

(get_simple_globs):

Location:
trunk/Source/ThirdParty
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/ThirdParty/ChangeLog

    r233255 r233404  
     12018-06-30  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        Fix off-by-one error in xdg_mime_get_simple_globs
     4        https://bugs.webkit.org/show_bug.cgi?id=186554
     5
     6        Reviewed by Daniel Bates.
     7
     8        We have an off-by-one error here in some code that was added for WebKit. (This is not an
     9        issue with upstream xdgmime.)
     10
     11        No new tests. This problem is caught by TestDownloads, but only when running with ASan
     12        enabled.
     13
     14        * xdgmime/src/xdgmimecache.c:
     15        (get_simple_globs):
     16        * xdgmime/src/xdgmimeglob.c:
     17        (get_simple_globs):
     18
    1192018-06-27  Michael Catanzaro  <mcatanzaro@igalia.com>
    220
  • trunk/Source/ThirdParty/xdgmime/src/xdgmimecache.c

    r233255 r233404  
    10481048  int i;
    10491049
     1050  assert (*n >= 0);
     1051  assert (depth >= 0);
     1052
    10501053  if (*n >= n_globs)
    10511054    return FALSE;
     
    10561059
    10571060      if (strcasecmp (cache->buffer + mime_offset, mime) == 0) {
    1058         globs[*n] = malloc (depth * sizeof (char));
     1061        globs[*n] = malloc ((depth + 1) * sizeof (char));
    10591062        for (i = 0; i < depth; i++)
    10601063          globs[*n][depth - i - 1] = prefix[i];
  • trunk/Source/ThirdParty/xdgmime/src/xdgmimeglob.c

    r214338 r233404  
    485485                  int              depth)
    486486{
     487  assert (*n >= 0);
     488  assert (depth >= 0);
     489
    487490  if (*n >= n_globs)
    488491    return FALSE;
     
    496499          int i;
    497500
    498           globs[*n] = malloc (depth * sizeof (char));
     501          globs[*n] = malloc ((depth + 1) * sizeof (char));
    499502          for (i = 0; i < depth; i++)
    500503            globs[*n][depth - i - 1] = prefix[i];
Note: See TracChangeset for help on using the changeset viewer.