summaryrefslogtreecommitdiffstats
path: root/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2013-02-16 13:21:35 +0000
committerRoy Marples <roy@marples.name>2013-02-16 13:21:35 +0000
commit28382337e143b12d5f001560b6248322131d0dbd (patch)
treeec7d34cfe34017d71a738e0fa712fa722639a40a /dhcpcd.c
parent17b0dbadd0456a129acf9d6836fb606a0024e60e (diff)
downloaddhcpcd-28382337e143b12d5f001560b6248322131d0dbd.tar.xz
Remove the xmalloc function.
Now we have removed all our xmalloc like functions dhcpcd can still try to operate as best it can in low memory conditions.
Diffstat (limited to 'dhcpcd.c')
-rw-r--r--dhcpcd.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/dhcpcd.c b/dhcpcd.c
index ad294553..50a455e5 100644
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -810,7 +810,11 @@ handle_args(struct fd_list *fd, int argc, char **argv)
len = 0;
for (opt = 0; opt < argc; opt++)
len += strlen(argv[opt]) + 1;
- tmp = p = xmalloc(len + 1);
+ tmp = p = malloc(len + 1);
+ if (tmp == NULL) {
+ syslog(LOG_ERR, "%s: %m", __func__);
+ return -1;
+ }
for (opt = 0; opt < argc; opt++) {
l = strlen(argv[opt]);
strlcpy(p, argv[opt], l + 1);
@@ -842,7 +846,7 @@ handle_args(struct fd_list *fd, int argc, char **argv)
/* We need at least one interface */
if (optind == argc) {
- syslog(LOG_ERR, "handle_args: no interface");
+ syslog(LOG_ERR, "%s: no interface", __func__);
return -1;
}
@@ -989,7 +993,11 @@ main(int argc, char **argv)
/* If we have any other args, we should run as a single dhcpcd
* instance for that interface. */
len = strlen(PIDFILE) + IF_NAMESIZE + 2;
- pidfile = xmalloc(len);
+ pidfile = malloc(len);
+ if (pidfile == NULL) {
+ syslog(LOG_ERR, "%s: %m", __func__);
+ exit(EXIT_FAILURE);
+ }
if (optind == argc - 1)
snprintf(pidfile, len, PIDFILE, "-", argv[optind]);
else {