From: msweet Date: Fri, 26 Apr 2013 18:59:41 +0000 (+0000) Subject: Nul-terminate the SNMP walk data that is provided before we use it as a C X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55803bd51e594541ae1a1844714487e266858583;p=thirdparty%2Fcups.git Nul-terminate the SNMP walk data that is provided before we use it as a C string... git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10969 7a7537e8-13f0-0310-91df-b6672ffda945 --- diff --git a/backend/testbackend.c b/backend/testbackend.c index 454533f5dd..722859f7f6 100644 --- a/backend/testbackend.c +++ b/backend/testbackend.c @@ -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); }