[gdal-dev] Resizing CPLErrorContext?

Kurt Schwehr schwehr at gmail.com
Tue May 16 07:01:53 PDT 2017


w.r.t. https://trac.osgeo.org/gdal/changeset/38405

Exactly why is it okay to resize this fixed size structure?

typedef struct {
    CPLErrorNum nLastErrNo;
    CPLErr  eLastErrType;
    CPLErrorHandlerNode *psHandlerStack;
    int     nLastErrMsgMax;
    int     nFailureIntoWarning;
    char    szLastErrMsg[DEFAULT_LAST_ERR_MSG_SIZE];
    // Do not add anything here. szLastErrMsg must be the last field.
    // See CPLRealloc() below.
} CPLErrorContext;

Your comment is:

CPLErrorSetState(): Workaround clang -fsanitize=undefined behaviour that
doesn't like dereferencing szLastErrMsg[i>=DEFAULT_LAST_ERR_MSG_SIZE] even
when structure has been properly resize. Fixes ​
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1628. Credit to OSS
Fuz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170516/fa1bfffb/attachment.html>


More information about the gdal-dev mailing list