* memset config before reading it
authorWilfried Göesgens <willi@citadel.org>
Tue, 5 Jan 2010 22:58:11 +0000 (22:58 +0000)
committerWilfried Göesgens <willi@citadel.org>
Tue, 5 Jan 2010 22:58:11 +0000 (22:58 +0000)
* warn if the file didn't have the size we expected

citadel/config.c

index bc42c559a76d36a8985c76e0d57766f406bd8c37..4c2509f0028d49b569814aec4fa07fa77926dcae 100644 (file)
@@ -67,7 +67,14 @@ void get_config(void) {
                                strerror(errno));
                exit(CTDLEXIT_CONFIG);
        }
+       memset(&config, 0, sizeof(struct config));
        rv = fread((char *) &config, sizeof(struct config), 1, cfp);
+       if (rv != sizeof(struct config))
+       {
+               fprintf(stderr, 
+                       "Warning: The config file %s has unexpected size. \n",
+                       file_citadel_config);
+       }
        if (fstat(fileno(cfp), &st)) {
                perror(file_citadel_config);
                exit(CTDLEXIT_CONFIG);