INN commit: trunk/storage/tradspool (tradspool.c)
INN Commit
rra at isc.org
Sun Jul 2 03:14:29 UTC 2017
Date: Saturday, July 1, 2017 @ 20:14:28
Author: eagle
Revision: 10159
Use xasprintf in tradspool
Replace xmalloc plus strlcpy and strlcat with a much simpler
xasprintf.
Modified:
trunk/storage/tradspool/tradspool.c
-------------+
tradspool.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
Modified: tradspool.c
===================================================================
--- tradspool.c 2017-07-02 03:00:07 UTC (rev 10158)
+++ tradspool.c 2017-07-02 03:14:28 UTC (rev 10159)
@@ -23,6 +23,7 @@
#include "inn/wire.h"
#include "inn/libinn.h"
#include "inn/paths.h"
+#include "inn/xmalloc.h"
#include "methods.h"
#include "tradspool.h"
@@ -1050,12 +1051,9 @@
bool flag;
char *path;
struct stat sb;
- size_t length;
- unsigned char namelen;
while ((de = readdir(dir)) != NULL) {
- namelen = strlen(de->d_name);
- for (i = 0, flag = true ; i < namelen ; ++i) {
+ for (i = 0, flag = true; de->d_name[i] != '\0'; i++) {
if (!isdigit((unsigned char) de->d_name[i])) {
flag = false;
break;
@@ -1062,13 +1060,7 @@
}
}
if (!flag) continue; /* if not all digits, skip this entry. */
-
- length = strlen(dirname) + namelen + 2;
- path = xmalloc(length);
- strlcpy(path, dirname, length);
- strlcat(path, "/", length);
- strlcat(path, de->d_name, length);
-
+ xasprintf(&path, "%s/%s", dirname, de->d_name);
if (lstat(path, &sb) < 0) {
free(path);
continue;
More information about the inn-committers
mailing list