/*
+ * $Id$
+ *
* Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* SOFTWARE.
*/
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$Id$";
-#endif /* LIBC_SCCS and not lint */
-
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
int nprinted;
nprinted = g_snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]);
- if (nprinted < 0)
- return (NULL); /* we assume "errno" was set by "g_snprintf()" */
- if ((size_t)nprinted > size) {
+ /* Note: nprinted *excludes* the trailing '\0' character */
+ if ((size_t)nprinted >= size) {
errno = ENOSPC;
return (NULL);
}
- strcpy(dst, tmp);
+ g_strlcpy(dst, tmp, size);
return (dst);
}
tp += strlen(tp);
break;
}
- tp += g_snprintf(tp, sizeof tmp - (tp - tmp), "%x", words[i]);
+ tp += g_snprintf(tp, (gulong) (sizeof tmp - (tp - tmp)), "%x", words[i]);
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) ==
errno = ENOSPC;
return (NULL);
}
- strcpy(dst, tmp);
+ g_strlcpy(dst, tmp, size);
return (dst);
}