aboutsummaryrefslogtreecommitdiff
path: root/conf
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@stoeckmann.org>2023-12-15 10:14:11 +0100
committerDmitry V. Levin <ldv@strace.io>2023-12-19 12:22:59 +0000
commit2e375aad04d047e12468f93300ad7e42a8a03ff3 (patch)
tree29f31fa0bf4700476eccd4a307ef6638d9707851 /conf
parentc2fafe1be0fb72aa1bd521efe2f524074bf143c7 (diff)
downloadpam-2e375aad04d047e12468f93300ad7e42a8a03ff3.tar.gz
pam-2e375aad04d047e12468f93300ad7e42a8a03ff3.tar.bz2
pam-2e375aad04d047e12468f93300ad7e42a8a03ff3.zip
treewide: use asprintf to construct strings
The asprintf function is considered as given for current code already. Use it instead of calling malloc + strcpy + strcat manually. Reported-by: Benny Baumann <BenBE@geshi.org> Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Diffstat (limited to 'conf')
-rw-r--r--conf/pam_conv1/pam_conv_y.y15
1 files changed, 8 insertions, 7 deletions
diff --git a/conf/pam_conv1/pam_conv_y.y b/conf/pam_conv1/pam_conv_y.y
index 72a5dab3..e2cf85c3 100644
--- a/conf/pam_conv1/pam_conv_y.y
+++ b/conf/pam_conv1/pam_conv_y.y
@@ -78,8 +78,10 @@ line
/* $1 = service-name */
yyerror("Appending to " PAM_D "/%s", $1);
- filename = malloc(strlen($1) + sizeof(PAM_D) + 6);
- sprintf(filename, PAM_D_FILE_FMT, $1);
+ if (asprintf(&filename, PAM_D_FILE_FMT, $1) < 0) {
+ yyerror("unable to create filename - aborting");
+ exit(1);
+ }
conf = fopen(filename, "r");
if (conf == NULL) {
/* new file */
@@ -140,12 +142,11 @@ tokenls
$$=NULL;
}
| tokenls tok {
- int len;
-
if ($1) {
- len = strlen($1) + strlen($2) + 2;
- $$ = malloc(len);
- sprintf($$,"%s %s",$1,$2);
+ if (asprintf(&$$, "%s %s", $1, $2) < 0) {
+ yyerror("failed to assemble tokenls");
+ exit(1);
+ }
free($1);
free($2);
} else {