]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Nul-terminate the SNMP walk data that is provided before we use it as a C
authormsweet <msweet@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 26 Apr 2013 18:59:41 +0000 (18:59 +0000)
committermsweet <msweet@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 26 Apr 2013 18:59:41 +0000 (18:59 +0000)
string...

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10969 7a7537e8-13f0-0310-91df-b6672ffda945

backend/testbackend.c

index 454533f5dd36f334a98ad24e50d31c73850ab39b..722859f7f69f56bbf8d51563355156dde5d5a844 100644 (file)
@@ -667,7 +667,19 @@ walk_cb(const char *oid,           /* I - OID */
        int        datalen,             /* I - Length of data */
        void       *context)            /* I - Context (unused) */
 {
-  printf("CUPS_SC_CMD_SNMP_WALK %s, %d bytes (%s)\n", oid, datalen, data);
+  char temp[80];
+  if (datalen > (sizeof(temp) - 1))
+  {
+    memcpy(temp, data, sizeof(temp) - 1);
+    temp[sizeof(temp) - 1] = '\0';
+  }
+  else
+  {
+    memcpy(temp, data, datalen);
+    temp[datalen] = '\0';
+  }
+
+  printf("CUPS_SC_CMD_SNMP_WALK %s, %d bytes (%s)\n", oid, datalen, temp);
 }