Source: net-snmp
Severity: normal
Tags: upstream patch

Dear Maintainer,


  In net-snmp 5.7.3 UTF-8 chars was never displayed, since revision [7f05da].
  This is in all debian packages for 5.7.3.

  Issue was fixed in upstream for upcoming releases.
  Original upstream issue: https://sourceforge.net/p/net-snmp/bugs/2815/
  There also more detailed issue description.

 Included patch tested with latest net-snmp packages in debian/ubuntu. 

-- System Information:
Debian Release: 8.10
  APT prefers oldstable-updates
  APT policy: (500, 'oldstable-updates'), (500, 'oldstable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.4.117-1-pve (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Description: BUG: 2815: Display UTF-8 characters again
 Before commit 7f05daa8e0e0 sprint_realloc_octet_string() used memcpy()
 for ASCII strings. That caused the output to be truncated if a '\0' was
 embedded in an octet string. Commit 7f05daa8e0e0 fixed that issue but
 broke UTF-8 support. Restore UTF-8 support by only using
 sprint_realloc_asciistring() if the octet string contains a '\0'.
 .
 net-snmp (5.7.3+dfsg-1ubuntu4.1) xenial; urgency=medium
 .
   * d/snmpd.init: also match start-stop-daemon against pidfile to avoid
     killing extra snmpd processes for example in container (LP: #1720109)
Author: Christian Ehrhardt <[email protected]>
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1720109

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: https://sourceforge.net/p/net-snmp/code/ci/4b518ed4971126dd874f64e0058347e9d622471b/tree/snmplib/mib.c?diff=40c09d42cad956eb0698c0e01ece9412f42966ed
Bug: https://sourceforge.net/p/net-snmp/bugs/2815/
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- net-snmp-5.7.3+dfsg.orig/snmplib/mib.c
+++ net-snmp-5.7.3+dfsg/snmplib/mib.c
@@ -570,10 +570,20 @@ sprint_realloc_octet_string(u_char ** bu
                     break;
                 case 't': /* new in rfc 3411 */
                 case 'a':
+                    /* A string hint gives the max size - we may not need this much */
                     cnt = SNMP_MIN(width, ecp - cp);
-                    if (!sprint_realloc_asciistring(buf, buf_len, out_len,
-                                                    allow_realloc, cp, cnt))
+                    while ((*out_len + cnt + 1) > *buf_len) {
+                        if (!allow_realloc || !snmp_realloc(buf, buf_len))
+                            return 0;
+                    }
+                    if (memchr(cp, '\0', cnt) == NULL) {
+                        /* No embedded '\0' - use strlcpy to preserve UTF-8 */
+                        strlcpy((char *)(*buf + *out_len), (char *)cp, cnt + 1);
+                        *out_len += cnt;
+                    } else if (!sprint_realloc_asciistring(buf, buf_len,
+                                     out_len, allow_realloc, cp, cnt)) {
                         return 0;
+                    }
                     cp += cnt;
                     break;
                 default:

Reply via email to