summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/userpref.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/userpref.c b/src/userpref.c
index d9dcaec..9b7a0a8 100644
--- a/src/userpref.c
+++ b/src/userpref.c
@@ -264,13 +264,19 @@ static int config_read(const char *cfgfile, plist_t *dict)
264 char line[256]; 264 char line[256];
265 fseek(fd, 0, SEEK_SET); 265 fseek(fd, 0, SEEK_SET);
266 while (fgets(line, 256, fd)) { 266 while (fgets(line, 256, fd)) {
267 size_t llen = strlen(line)-1; 267 char *p = &line[0];
268 while ((llen > 0) && ((line[llen] == '\n') || (line[llen] == '\r'))) { 268 size_t llen = strlen(p)-1;
269 line[llen] = '\0'; 269 while ((llen > 0) && ((p[llen] == '\n') || (p[llen] == '\r'))) {
270 p[llen] = '\0';
271 llen--;
270 } 272 }
271 if (!strncmp(line, "HostID=", 7)) { 273 if (llen == 0) continue;
274 while ((p[0] == '\n') || (p[0] == '\r')) {
275 p++;
276 }
277 if (!strncmp(p, "HostID=", 7)) {
272 plist = plist_new_dict(); 278 plist = plist_new_dict();
273 plist_dict_insert_item(plist, "HostID", plist_new_string(line+7)); 279 plist_dict_insert_item(plist, "HostID", plist_new_string(p+7));
274 break; 280 break;
275 } 281 }
276 } 282 }