diff options
| author | Roy Marples <roy@marples.name> | 2013-02-16 13:21:35 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2013-02-16 13:21:35 +0000 |
| commit | 28382337e143b12d5f001560b6248322131d0dbd (patch) | |
| tree | ec7d34cfe34017d71a738e0fa712fa722639a40a /dhcpcd.c | |
| parent | 17b0dbadd0456a129acf9d6836fb606a0024e60e (diff) | |
| download | dhcpcd-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.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -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 { |
