diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2012-06-02 09:59:54 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-06-02 09:59:54 -0700 |
commit | 758fb6cde3ee6ab53aa6b4b07a2acc2bde0b6c5d (patch) | |
tree | 4ddada103fbdd2765054517caa9520b7da4818e6 | |
parent | 8eab1fdd0eea4740b802c2994446259b4dea808c (diff) | |
parent | ad7502a6aeff431e9759e57734474576d4b085e7 (diff) | |
download | android_external_dnsmasq-758fb6cde3ee6ab53aa6b4b07a2acc2bde0b6c5d.tar.gz android_external_dnsmasq-758fb6cde3ee6ab53aa6b4b07a2acc2bde0b6c5d.tar.bz2 android_external_dnsmasq-758fb6cde3ee6ab53aa6b4b07a2acc2bde0b6c5d.zip |
am ad7502a6: Merge "Ensure all commands read on dnsmasq\'s stdin are processed"
* commit 'ad7502a6aeff431e9759e57734474576d4b085e7':
Ensure all commands read on dnsmasq's stdin are processed
-rwxr-xr-x | src/dnsmasq.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/dnsmasq.c b/src/dnsmasq.c index 1a9d808..f6b371a 100755 --- a/src/dnsmasq.c +++ b/src/dnsmasq.c @@ -984,32 +984,40 @@ static int set_android_listeners(fd_set *set, int *maxfdp) { } static int check_android_listeners(fd_set *set) { + int retcode = 0; if (FD_ISSET(STDIN_FILENO, set)) { char buffer[1024]; int rc; + int consumed = 0; if ((rc = read(STDIN_FILENO, buffer, sizeof(buffer) -1)) < 0) { my_syslog(LOG_ERR, _("Error reading from stdin (%s)"), strerror(errno)); return -1; } buffer[rc] = '\0'; - char *next = buffer; - char *cmd; - - if (!(cmd = strsep(&next, ":"))) { - my_syslog(LOG_ERR, _("Malformatted msg '%s'"), buffer); - return -1; - } - - if (!strcmp(buffer, "update_dns")) { - set_servers(&buffer[11]); - check_servers(); - } else { - my_syslog(LOG_ERR, _("Unknown cmd '%s'"), cmd); - return -1; + while(consumed < rc) { + char *cmd; + char *current_cmd = &buffer[consumed]; + char *params = current_cmd; + int len = strlen(current_cmd); + + cmd = strsep(¶ms, ":"); + if (!strcmp(cmd, "update_dns")) { + if (params != NULL) { + set_servers(params); + check_servers(); + } else { + my_syslog(LOG_ERR, _("Malformatted msg '%s'"), current_cmd); + retcode = -1; + } + } else { + my_syslog(LOG_ERR, _("Unknown cmd '%s'"), cmd); + retcode = -1; + } + consumed += len + 1; } } - return 0; + return retcode; } #endif |