@@ -123,8 +123,12 @@ struct flb_az_li* flb_az_li_ctx_create(struct flb_output_instance *ins,
123
123
flb_az_li_ctx_destroy (ctx );
124
124
return NULL ;
125
125
}
126
- flb_sds_snprintf (& ctx -> auth_url , flb_sds_alloc (ctx -> auth_url ),
127
- FLB_AZ_LI_MSIAUTH_URL_TEMPLATE , "" , "" );
126
+ if (flb_sds_snprintf (& ctx -> auth_url , flb_sds_alloc (ctx -> auth_url ),
127
+ FLB_AZ_LI_MSIAUTH_URL_TEMPLATE , "" , "" ) < 0 ) {
128
+ flb_plg_error (ins , "failed to build auth URL for system-assigned managed identity" );
129
+ flb_az_li_ctx_destroy (ctx );
130
+ return NULL ;
131
+ }
128
132
}
129
133
else if (ctx -> auth_type == FLB_AZ_LI_AUTH_MANAGED_IDENTITY_USER ) {
130
134
/* User-assigned managed identity */
@@ -136,8 +140,12 @@ struct flb_az_li* flb_az_li_ctx_create(struct flb_output_instance *ins,
136
140
flb_az_li_ctx_destroy (ctx );
137
141
return NULL ;
138
142
}
139
- flb_sds_snprintf (& ctx -> auth_url , flb_sds_alloc (ctx -> auth_url ),
140
- FLB_AZ_LI_MSIAUTH_URL_TEMPLATE , "&client_id=" , ctx -> client_id );
143
+ if (flb_sds_snprintf (& ctx -> auth_url , flb_sds_alloc (ctx -> auth_url ),
144
+ FLB_AZ_LI_MSIAUTH_URL_TEMPLATE , "&client_id=" , ctx -> client_id ) < 0 ) {
145
+ flb_plg_error (ins , "failed to build auth URL for user-assigned managed identity" );
146
+ flb_az_li_ctx_destroy (ctx );
147
+ return NULL ;
148
+ }
141
149
}
142
150
else {
143
151
/* Service principal authentication */
@@ -148,8 +156,12 @@ struct flb_az_li* flb_az_li_ctx_create(struct flb_output_instance *ins,
148
156
flb_az_li_ctx_destroy (ctx );
149
157
return NULL ;
150
158
}
151
- flb_sds_snprintf (& ctx -> auth_url , flb_sds_alloc (ctx -> auth_url ),
152
- FLB_AZ_LI_AUTH_URL_TMPLT , ctx -> tenant_id );
159
+ if (flb_sds_snprintf (& ctx -> auth_url , flb_sds_alloc (ctx -> auth_url ),
160
+ FLB_AZ_LI_AUTH_URL_TMPLT , ctx -> tenant_id ) < 0 ) {
161
+ flb_plg_error (ins , "failed to build auth URL for service principal" );
162
+ flb_az_li_ctx_destroy (ctx );
163
+ return NULL ;
164
+ }
153
165
}
154
166
155
167
/* Allocate and set dce full url */
@@ -180,8 +192,7 @@ struct flb_az_li* flb_az_li_ctx_create(struct flb_output_instance *ins,
180
192
181
193
/* Create upstream context for Log Ingsetion endpoint */
182
194
ctx -> u_dce = flb_upstream_create_url (config , ctx -> dce_url ,
183
- FLB_AZ_LI_TLS_MODE , ins -> tls );
184
- if (!ctx -> u_dce ) {
195
+ FLB_AZ_LI_TLS_MODE , ins -> tls ); if (!ctx -> u_dce ) {
185
196
flb_plg_error (ins , "upstream creation failed" );
186
197
flb_az_li_ctx_destroy (ctx );
187
198
return NULL ;
0 commit comments