mirror of
https://github.com/Yubico/yubico-pam.git
synced 2025-03-14 06:29:21 +01:00
ykpamcfg.c: Check also for negative return code of snprintf()
This commit is contained in:
parent
f94095879a
commit
2f172e3227
@ -95,6 +95,7 @@ parse_args(int argc, char **argv,
|
|||||||
unsigned int *iterations)
|
unsigned int *iterations)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
int i;
|
||||||
|
|
||||||
while((c = getopt(argc, argv, optstring)) != -1) {
|
while((c = getopt(argc, argv, optstring)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@ -105,7 +106,8 @@ parse_args(int argc, char **argv,
|
|||||||
*slot = 2;
|
*slot = 2;
|
||||||
break;
|
break;
|
||||||
case 'A':
|
case 'A':
|
||||||
if (snprintf(*action, ACTION_MAX_LEN, "%s", optarg) >= ACTION_MAX_LEN) {
|
i = snprintf(*action, ACTION_MAX_LEN, "%s", optarg);
|
||||||
|
if (i < 0 || i >= ACTION_MAX_LEN) {
|
||||||
fprintf(stderr, "action too long: %s\n", optarg);
|
fprintf(stderr, "action too long: %s\n", optarg);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user