diff options
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util_str.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index d1e57ed5cf..4d955c59a7 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -603,8 +603,12 @@ char *StrnCpy_fn(const char *fn, int line,char *dest,const char *src,size_t n) *dest = 0; return(dest); } - while (n-- && (*d++ = *src++)) - ; + + while (n-- && (*d = *src)) { + d++; + src++; + } + *d = 0; return(dest); } @@ -682,6 +686,22 @@ size_t strhex_to_str(char *p, size_t len, const char *strhex) } /** + * Routine to print a buffer as HEX digits, into an allocated string. + */ + +void hex_encode(const unsigned char *buff_in, size_t len, char **out_hex_buffer) +{ + int i; + char *hex_buffer; + + *out_hex_buffer = smb_xmalloc((len*2)+1); + hex_buffer = *out_hex_buffer; + + for (i = 0; i < len; i++) + slprintf(&hex_buffer[i*2], 3, "%02X", buff_in[i]); +} + +/** Check if a string is part of a list. **/ |