This patch fixes a bug in the padding of umb strings. Instead of
padding the right position, umb_padding() would always zero padding
bytes at the beginning of the buffer.

For the two callers of umb_addstr(), this won't hurt in
umb_send_connect() since the first value in the buffer is the
session id, which is zero anyway. But for umb_setpin() we might try to
change the wrong type of PIN, iff the length of the PIN is not a
multiple of 4.

Gerhard


Index: sys/dev/usb/if_umb.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/if_umb.c,v
retrieving revision 1.7
diff -u -p -u -p -r1.7 if_umb.c
--- sys/dev/usb/if_umb.c        21 Nov 2016 08:19:36 -0000      1.7
+++ sys/dev/usb/if_umb.c        22 Nov 2016 11:41:49 -0000
@@ -1211,7 +1211,7 @@ umb_padding(void *data, int len, size_t 
        int      np = 0;
 
        while (len < sz && (len % 4) != 0) {
-               *p++ = '\0';
+               *(p + len) = '\0';
                len++;
                np++;
        }

Reply via email to