- if (isalpha(buffer[count - 1])) {
- if (buffer[count - 1] != 'B') {
- scnprintf(param, sizeof(param), "%.*siB",
- (int)count, buffer);
- } else {
- memcpy(param, buffer, sizeof(param));
+ /* If there isn't already a unit on this value, append @defunit.
+ * Units of 'B' don't affect the value, so don't bother adding.
+ */
+ if (!isalpha(buffer[count - 1]) && defunit[0] != 'B') {
+ if (count + 3 >= sizeof(tmp_buf)) {
+ CERROR("count %zd > size %zd\n", count, sizeof(param));
+ RETURN(-E2BIG);