Line
Link Here
|
0 |
-- kdm/backend/inifile.c |
0 |
++ kdm/backend/inifile.c |
Lines 37-42
Link Here
|
37 |
#include "dm_error.h" |
37 |
#include "dm_error.h" |
38 |
|
38 |
|
39 |
#include <sys/types.h> |
39 |
#include <sys/types.h> |
|
|
40 |
#include <sys/stat.h> |
40 |
#include <unistd.h> |
41 |
#include <unistd.h> |
41 |
#include <stdlib.h> |
42 |
#include <stdlib.h> |
42 |
#include <string.h> |
43 |
#include <string.h> |
Lines 47-63
Link Here
|
47 |
{ |
48 |
{ |
48 |
char *data; |
49 |
char *data; |
49 |
int fd, len; |
50 |
int fd, len; |
|
|
51 |
struct stat st; |
50 |
|
52 |
|
51 |
if ((fd = open( fname, O_RDONLY | O_NONBLOCK )) < 0) { |
53 |
if ((fd = open( fname, O_RDONLY | O_NONBLOCK )) < 0) { |
52 |
Debug( "cannot open ini-file %\"s: %m", fname ); |
54 |
Debug( "cannot open ini-file %\"s: %m", fname ); |
53 |
return 0; |
55 |
return 0; |
54 |
} |
56 |
} |
55 |
len = lseek( fd, 0, SEEK_END ); |
57 |
if (fstat( fd, &st ) || !S_ISREG( st.st_mode )) { |
|
|
58 |
LogWarn( "Ini-file %\"s is no regular file\n", fname ); |
59 |
close( fd ); |
60 |
return 0; |
61 |
} |
62 |
if (st.st_size >= 0x10000) { |
63 |
LogWarn( "Ini-file %\"s is too big\n", fname ); |
64 |
close( fd ); |
65 |
return 0; |
66 |
} |
67 |
len = st.st_size; |
56 |
if (!(data = Malloc( len + 2 ))) { |
68 |
if (!(data = Malloc( len + 2 ))) { |
57 |
close( fd ); |
69 |
close( fd ); |
58 |
return 0; |
70 |
return 0; |
59 |
} |
71 |
} |
60 |
lseek( fd, 0, SEEK_SET ); |
|
|
61 |
if (read( fd, data, len ) != len) { |
72 |
if (read( fd, data, len ) != len) { |
62 |
Debug( "cannot read ini-file %\"s: %m", fname ); |
73 |
Debug( "cannot read ini-file %\"s: %m", fname ); |
63 |
free( data ); |
74 |
free( data ); |