[tracker/wip/carlosg/graphs: 2/4] libtracker-sparql: Fix off-by-one error in TrackerNamespaceManager



commit 6fd0376b36402e06af60e00adb11f07b3309b171
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Apr 29 18:51:17 2020 +0200

    libtracker-sparql: Fix off-by-one error in TrackerNamespaceManager
    
    When expanding a prefixed form (e.g. nie:url) into a full blown URL,
    the anchor point would be set around the colon character, but we on
    one hand were 1 char short when using the prefix for comparisons
    (e.g. "ni" instead of "nie"), and still paste the colon character
    when expanding the URI.
    
    Move this around so the prefix has one char more, and the suffix one
    char less.

 src/libtracker-sparql/tracker-namespace-manager.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-sparql/tracker-namespace-manager.c 
b/src/libtracker-sparql/tracker-namespace-manager.c
index d7eda17df..ed088e4c8 100644
--- a/src/libtracker-sparql/tracker-namespace-manager.c
+++ b/src/libtracker-sparql/tracker-namespace-manager.c
@@ -287,7 +287,7 @@ tracker_namespace_manager_expand_uri (TrackerNamespaceManager *self,
        if (colon != NULL) {
                int colon_pos = colon - compact_uri;
                if (colon_pos < MAX_PREFIX_LENGTH) {
-                       strncpy (prefix, compact_uri, colon_pos - 1);
+                       strncpy (prefix, compact_uri, colon_pos);
                        prefix[colon_pos] = 0;
 
                        namespace = g_hash_table_lookup (priv->prefix_to_namespace, prefix);
@@ -295,7 +295,7 @@ tracker_namespace_manager_expand_uri (TrackerNamespaceManager *self,
        }
 
        if (namespace) {
-               return g_strconcat (namespace, colon, NULL);
+               return g_strconcat (namespace, colon + 1, NULL);
        } else {
                return g_strdup (compact_uri);
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]