From: Matthew Fernandez Date: Sat, 29 May 2021 20:59:31 +0000 (-0700) Subject: remove temporary buffer for the name of registered GVC plugins X-Git-Tag: 2.47.3~15^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b397354116a6d5b26504a5bda456c2f067ff8db2;p=graphviz remove temporary buffer for the name of registered GVC plugins Similar to the previous commit, this removes a temporary buffer that was only being used for splitting a name on a ':' separator. Using the same strategy of maintaining start and end as pointers into the original string, we can remove the need for the temporary buffer and remove the limitation on ≤63 character names. --- diff --git a/CHANGELOG.md b/CHANGELOG.md index f19477bc1..c0d67f9f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - marginally more accurate computations in Smyrna sphere projection - Perl is no longer required to build Graphviz #2067 - nop more reliably returns success and failure exit statuses +- implicit 63 character limit on plugin names is removed in GVC ### Fixed diff --git a/lib/gvc/gvplugin.c b/lib/gvc/gvplugin.c index 402fe36b9..b3d54f84c 100644 --- a/lib/gvc/gvplugin.c +++ b/lib/gvc/gvplugin.c @@ -261,9 +261,6 @@ gvplugin_available_t *gvplugin_load(GVC_t * gvc, api_t api, const char *str) gvplugin_library_t *library; gvplugin_api_t *apis; gvplugin_installed_t *types; -#define TYPBUFSIZ 64 - char typ[TYPBUFSIZ] = {0}; - char *dep = NULL; int i; api_t apidep; @@ -297,11 +294,14 @@ gvplugin_available_t *gvplugin_load(GVC_t * gvc, api_t api, const char *str) /* iterate the linked list of plugins for this api */ for (pnext = gvc->apis[api]; pnext; pnext = pnext->next) { - strncpy(typ, pnext->typestr, TYPBUFSIZ - 1); - dep = strchr(typ, ':'); - if (dep) - *dep++ = '\0'; - if (strlen(typ) != reqtyp_len || strncmp(typ, reqtyp, reqtyp_len)) + const char *typ = pnext->typestr; + const char *typ_end = strchr(typ, ':'); + size_t typ_len = + typ_end == NULL ? strlen(typ) : (size_t)(typ_end - typ); + + const char *dep = typ_end == NULL ? NULL : (typ_end + strlen(":")); + + if (typ_len != reqtyp_len || strncmp(typ, reqtyp, reqtyp_len)) continue; /* types empty or mismatched */ if (dep && reqdep) { if (strlen(dep) != reqdep_len || strncmp(dep, reqdep, reqdep_len)) {