# HG changeset patch # User meillo@marmaro.de # Date 1225962809 -3600 # Node ID 99c09ed776c1499520e9f373be36748ce182cdf6 # Parent 6c59dedd06bec407110f623940d4ac8e07575e6e fixed empty or only-whitespace connection names (Closes Debian bug #427095) stripping leading and trailing whitespace from connection names diff -r 6c59dedd06be -r 99c09ed776c1 src/online.c --- a/src/online.c Thu Nov 06 09:41:35 2008 +0100 +++ b/src/online.c Thu Nov 06 10:13:29 2008 +0100 @@ -46,8 +46,16 @@ if (in != NULL) { gchar output[256]; if (fgets(output, 255, in)) { - g_strchomp(output); - name = g_strdup(output); + g_strchomp(g_strchug(output)); + if (strlen(output) == 0) { + logwrite(LOG_ALERT, "only whitespace connection name\n"); + name = NULL; + } else { + name = g_strdup(output); + } + } else { + logwrite(LOG_ALERT, "nothing read from pipe %s\n", pipe); + name = NULL; } fclose(in); waitpid(pid, &status, 0); @@ -75,9 +83,17 @@ FILE *fptr = fopen(conf.online_file, "r"); if (fptr) { char buf[256]; - fgets(buf, 256, fptr); - g_strchomp(buf); + if (fgets(buf, 256, fptr) == NULL) { + logwrite(LOG_ALERT, "empty online file %s\n", conf.online_file); + fclose(fptr); + return NULL; + } + g_strchomp(g_strchug(buf)); fclose(fptr); + if (strlen(buf) == 0) { + logwrite(LOG_ALERT, "only whitespace connection name in %s\n", conf.online_file); + return NULL; + } return g_strdup(buf); } else { logwrite(LOG_ALERT, "opening of %s failed: %s\n", conf.online_file, strerror(errno));