]> granicus.if.org Git - graphviz/commitdiff
remove temporary buffer for the name of registered GVC plugins
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 29 May 2021 20:59:31 +0000 (13:59 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 5 Jun 2021 01:57:32 +0000 (18:57 -0700)
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.

CHANGELOG.md
lib/gvc/gvplugin.c

index f19477bc14cd3a0c28ca75927cc5a0d8d42508fe..c0d67f9f2de14c5da9b3fb4dc896632ea650b9bd 100644 (file)
@@ -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
 
index 402fe36b9395498ac404ab1b9c2543d1b88bea7e..b3d54f84c2a7548742bf74f4335f6923ac598ee3 100644 (file)
@@ -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)) {