Refactored sam functions to utilize strtok_s

This commit is contained in:
akallabeth 2020-05-18 12:07:59 +02:00
parent 7890833af8
commit ddb388e152
2 changed files with 13 additions and 10 deletions

View File

@ -23,13 +23,6 @@
#include <winpr/winpr.h>
#include <winpr/wtypes.h>
struct winpr_sam
{
FILE* fp;
char* line;
char* buffer;
BOOL readOnly;
};
typedef struct winpr_sam WINPR_SAM;
struct winpr_sam_entry

View File

@ -43,6 +43,15 @@
#endif
#define TAG WINPR_TAG("utils")
struct winpr_sam
{
FILE* fp;
char* line;
char* buffer;
char* context;
BOOL readOnly;
};
WINPR_SAM* SamOpen(const char* filename, BOOL readOnly)
{
FILE* fp = NULL;
@ -98,6 +107,7 @@ static BOOL SamLookupStart(WINPR_SAM* sam)
if (fileSize < 1)
return FALSE;
sam->context = NULL;
sam->buffer = (char*)malloc(fileSize + 2);
if (!sam->buffer)
@ -120,7 +130,7 @@ static BOOL SamLookupStart(WINPR_SAM* sam)
sam->buffer[fileSize] = '\n';
sam->buffer[fileSize + 1] = '\0';
sam->line = strtok(sam->buffer, "\n");
sam->line = strtok_s(sam->buffer, "\n", &sam->context);
return TRUE;
}
@ -300,7 +310,7 @@ WINPR_SAM_ENTRY* SamLookupUserA(WINPR_SAM* sam, LPSTR User, UINT32 UserLength, L
}
SamResetEntry(entry);
sam->line = strtok(NULL, "\n");
sam->line = strtok_s(NULL, "\n", sam->context);
}
out_fail:
@ -415,7 +425,7 @@ WINPR_SAM_ENTRY* SamLookupUserW(WINPR_SAM* sam, LPWSTR User, UINT32 UserLength,
}
SamResetEntry(entry);
sam->line = strtok(NULL, "\n");
sam->line = strtok_s(NULL, "\n", sam->context);
}
out_fail: