Skip to content
Snippets Groups Projects
Commit 0aac66f7 authored by rswindell's avatar rswindell
Browse files

Added code to putusername() to automatically fix a corrupted name.dat file.

parent 88e81e94
Branches
Tags
No related merge requests found
...@@ -523,6 +523,7 @@ int DLLCALL putusername(scfg_t* cfg, int number, char *name) ...@@ -523,6 +523,7 @@ int DLLCALL putusername(scfg_t* cfg, int number, char *name)
char str[256]; char str[256];
int file; int file;
long length; long length;
uint total_users;
if (number<1) if (number<1)
return(-1); return(-1);
...@@ -531,6 +532,12 @@ int DLLCALL putusername(scfg_t* cfg, int number, char *name) ...@@ -531,6 +532,12 @@ int DLLCALL putusername(scfg_t* cfg, int number, char *name)
if((file=nopen(str,O_RDWR|O_CREAT))==-1) if((file=nopen(str,O_RDWR|O_CREAT))==-1)
return(-2); return(-2);
length=filelength(file); length=filelength(file);
/* Truncate corrupted name.dat */
total_users=lastuser(cfg);
if((uint)(length/(LEN_ALIAS+2))>total_users)
chsize(file,total_users*(LEN_ALIAS+2));
if(length && length%(LEN_ALIAS+2)) { if(length && length%(LEN_ALIAS+2)) {
close(file); close(file);
return(-3); return(-3);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment