mirror of
https://github.com/Yubico/yubico-pam.git
synced 2025-03-06 09:29:17 +01:00
Make use of PATH_MAX for fullpath
Instead of hardcoding the buffer size to 256, using PATH_MAX makes more sense here, since this can be defined differently on different platforms. This is not perfect, though, refer to [1] for some details. In our case it should be good enough. [1]: https://eklitzke.org/path-max-is-tricky
This commit is contained in:
parent
fa3833b0a0
commit
daad39345d
@ -39,6 +39,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include <ykpers.h>
|
#include <ykpers.h>
|
||||||
|
|
||||||
@ -164,8 +165,8 @@ do_add_hmac_chalresp(YK_KEY *yk, uint8_t slot, bool verbose, char *output_dir, u
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (!output_dir){
|
if (!output_dir){
|
||||||
char fullpath[256];
|
char fullpath[PATH_MAX];
|
||||||
snprintf(fullpath, 256,"%s/.yubico",p->pw_dir);
|
snprintf(fullpath, PATH_MAX, "%s/.yubico", p->pw_dir);
|
||||||
|
|
||||||
//check if directory exists
|
//check if directory exists
|
||||||
if (stat(fullpath,&st)!=0 ){
|
if (stat(fullpath,&st)!=0 ){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user