mirror of
https://github.com/Yubico/yubico-pam.git
synced 2025-02-20 12:54:16 +01:00
fixup warnings related to constness of filename
This commit is contained in:
parent
076a8d2f3f
commit
9c913fd97e
18
util.c
18
util.c
@ -293,8 +293,8 @@ get_user_challenge_file(YK_KEY *yk, const char *chalresp_path, const char *usern
|
|||||||
* the option chalresp_path can be used to point to a system-wide directory.
|
* the option chalresp_path can be used to point to a system-wide directory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *filename; /* not including directory */
|
const char *filename = NULL; /* not including directory */
|
||||||
int filename_malloced = 0;
|
char *ptr = NULL;
|
||||||
unsigned int serial = 0;
|
unsigned int serial = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -303,18 +303,18 @@ get_user_challenge_file(YK_KEY *yk, const char *chalresp_path, const char *usern
|
|||||||
if (! chalresp_path)
|
if (! chalresp_path)
|
||||||
filename = "challenge";
|
filename = "challenge";
|
||||||
else
|
else
|
||||||
filename = (char *) username;
|
filename = username;
|
||||||
} else {
|
} else {
|
||||||
/* We have serial number */
|
/* We have serial number */
|
||||||
int len;
|
int len;
|
||||||
/* 0xffffffff == 4294967295 == 10 digits */
|
/* 0xffffffff == 4294967295 == 10 digits */
|
||||||
len = strlen(chalresp_path == NULL ? "challenge" : username) + 1 + 10 + 1;
|
len = strlen(chalresp_path == NULL ? "challenge" : username) + 1 + 10 + 1;
|
||||||
if ((filename = malloc(len)) != NULL) {
|
if ((ptr = malloc(len)) != NULL) {
|
||||||
int res = snprintf(filename, len, "%s-%u", chalresp_path == NULL ? "challenge" : username, serial);
|
int res = snprintf(ptr, len, "%s-%u", chalresp_path == NULL ? "challenge" : username, serial);
|
||||||
filename_malloced = 1;
|
filename = ptr;
|
||||||
if (res < 0 || res > len) {
|
if (res < 0 || res > len) {
|
||||||
/* Not enough space, strangely enough. */
|
/* Not enough space, strangely enough. */
|
||||||
free(filename);
|
free(ptr);
|
||||||
filename = NULL;
|
filename = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -324,8 +324,8 @@ get_user_challenge_file(YK_KEY *yk, const char *chalresp_path, const char *usern
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = get_user_cfgfile_path (chalresp_path, filename, username, fn);
|
ret = get_user_cfgfile_path (chalresp_path, filename, username, fn);
|
||||||
if(filename_malloced == 1) {
|
if(ptr) {
|
||||||
free(filename);
|
free(ptr);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user