diff options
author | Nikias Bassen | 2011-10-08 19:27:36 +0200 |
---|---|---|
committer | Martin Szulecki | 2012-03-19 01:45:30 +0100 |
commit | 38171bc2332dc68b86ea627e50c482e2ace4e342 (patch) | |
tree | 1eef052f2b23fe1e2d14da5a782db139f1208a84 /src | |
parent | 6e092c84d060fe4e0e9ddea8801c42425cd59afa (diff) | |
download | libimobiledevice-38171bc2332dc68b86ea627e50c482e2ace4e342.tar.gz libimobiledevice-38171bc2332dc68b86ea627e50c482e2ace4e342.tar.bz2 |
userprefs: fix 0x0d,0x0a config file parsing on win32
Diffstat (limited to 'src')
-rw-r--r-- | src/userpref.c | 16 |
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) char line[256]; fseek(fd, 0, SEEK_SET); while (fgets(line, 256, fd)) { - size_t llen = strlen(line)-1; - while ((llen > 0) && ((line[llen] == '\n') || (line[llen] == '\r'))) { - line[llen] = '\0'; + char *p = &line[0]; + size_t llen = strlen(p)-1; + while ((llen > 0) && ((p[llen] == '\n') || (p[llen] == '\r'))) { + p[llen] = '\0'; + llen--; } - if (!strncmp(line, "HostID=", 7)) { + if (llen == 0) continue; + while ((p[0] == '\n') || (p[0] == '\r')) { + p++; + } + if (!strncmp(p, "HostID=", 7)) { plist = plist_new_dict(); - plist_dict_insert_item(plist, "HostID", plist_new_string(line+7)); + plist_dict_insert_item(plist, "HostID", plist_new_string(p+7)); break; } } |