/*
* This file is part of DisOrder
- * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
+ * Copyright (C) 2004, 2005, 2007-9, 2013 Richard Kettlewell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "hex.h"
#include "mem.h"
#include "log.h"
+#include "printf.h"
/** @brief Convert a byte sequence to hex
* @param ptr Pointer to first byte
char *buf = xmalloc_noptr(n * 2 + 1), *p = buf;
while(n-- > 0)
- p += sprintf(p, "%02x", (unsigned)*ptr++);
+ p += byte_snprintf(p, 3, "%02x", (unsigned)*ptr++);
*p = 0;
return buf;
}
int unhexdigit(int c) {
int d;
- if((d = unhexdigitq(c)) < 0) error(0, "invalid hex digit");
+ if((d = unhexdigitq(c)) < 0)
+ disorder_error(0, "invalid hex digit");
return d;
}
int d1, d2;
if((l = strlen(s)) & 1) {
- error(0, "hex string has odd length");
+ disorder_error(0, "hex string has odd length");
return 0;
}
p = buf = xmalloc_noptr(l / 2);