Handle zero-length legacy netconfig files correctly (just delete them)
authorArt Cancro <ajc@citadel.org>
Mon, 18 Jan 2016 02:31:44 +0000 (21:31 -0500)
committerArt Cancro <ajc@citadel.org>
Mon, 18 Jan 2016 02:31:44 +0000 (21:31 -0500)
citadel/modules/rssclient/serv_rssclient.c
citadel/netconfig.c

index 5893fe76b73b157822d8f0f3d6cda5195d0a7b0a..acae637871a5830a0b3aac56ead9ab2662b36738 100644 (file)
@@ -772,6 +772,8 @@ void rssclient_scan_room(struct ctdlroom *qrbuf, void *data, OneRoomNetCfg *OneR
        rss_aggregator *use_this_RSSAggr = NULL;
        void *vptr;
 
+       TRACE;
+
        pthread_mutex_lock(&RSSQueueMutex);
        if (GetHash(RSSQueueRooms, LKEY(qrbuf->QRnumber), &vptr))
        {
index 55d98d1ae148dd1cc238a47b771cade392ddbdb3..d87d522cbfe56e0e9608f4a575c90be1ac2694b3 100644 (file)
@@ -931,14 +931,19 @@ void convert_legacy_netcfg_files(void)
                        if (fp) {
                                fseek(fp, 0L, SEEK_END);
                                len = ftell(fp);
-                               v = malloc(len);
-                               if (v) {
-                                       rewind(fp);
-                                       if (fread(v, len, 1, fp)) {
-                                               write_netconfig_to_configdb(roomnum, v);
-                                               unlink(filename);
+                               if (len > 0) {
+                                       v = malloc(len);
+                                       if (v) {
+                                               rewind(fp);
+                                               if (fread(v, len, 1, fp)) {
+                                                       write_netconfig_to_configdb(roomnum, v);
+                                                       unlink(filename);
+                                               }
+                                               free(v);
                                        }
-                                       free(v);
+                               }
+                               else {
+                                       unlink(filename);       // zero length netconfig, just delete it
                                }
                                fclose(fp);
                        }