diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-05-31 10:02:01 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-05-31 10:02:01 +0000 |
commit | 52ee0a693d68ca8b7c02a64bc4fe20a38d500a21 (patch) | |
tree | 8c81be80f1b97749e4927035a2635756d1368417 /pw/pw.c | |
parent | 5072ef108f3befb866c08ae706c33db202bf3c88 (diff) | |
download | pw-darwin-52ee0a693d68ca8b7c02a64bc4fe20a38d500a21.tar.gz pw-darwin-52ee0a693d68ca8b7c02a64bc4fe20a38d500a21.tar.zst pw-darwin-52ee0a693d68ca8b7c02a64bc4fe20a38d500a21.zip |
Use asprintf instead of malloc + snprintf and test the memory allocation
Diffstat (limited to 'pw/pw.c')
-rw-r--r-- | pw/pw.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -221,8 +221,9 @@ main(int argc, char *argv[]) char * etcpath = getarg(&arglist, 'V')->val; if (*etcpath) { if (config == NULL) { /* Only override config location if -C not specified */ - config = malloc(MAXPATHLEN); - snprintf(config, MAXPATHLEN, "%s/pw.conf", etcpath); + asprintf(&config, "%s/pw.conf", etcpath); + if (config == NULL) + errx(EX_OSERR, "out of memory"); } memcpy(&PWF, &VPWF, sizeof PWF); setpwdir(etcpath); |