(quote_string): don't sign extend the (signed) char to avoid printing
too much, add an assert to check that we didn't overrun the buffer. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20891 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -82,11 +82,12 @@ quote_string(const char *f, size_t len, size_t *rlen)
|
|||||||
to[j++] = from[i];
|
to[j++] = from[i];
|
||||||
} else {
|
} else {
|
||||||
int l = snprintf(&to[j], tolen - j - 1,
|
int l = snprintf(&to[j], tolen - j - 1,
|
||||||
"#%02x", (unsigned int)from[i]);
|
"#%02x", (unsigned char)from[i]);
|
||||||
j += l;
|
j += l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
to[j] = '\0';
|
to[j] = '\0';
|
||||||
|
assert(j < tolen);
|
||||||
*rlen = j;
|
*rlen = j;
|
||||||
return to;
|
return to;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user