OSDN Git Service

fixed config parser.
authorTaizo ITO <taizo.ito@hde.co.jp>
Tue, 23 Jun 2009 03:18:52 +0000 (12:18 +0900)
committerTaizo ITO <taizo.ito@hde.co.jp>
Tue, 23 Jun 2009 03:18:52 +0000 (12:18 +0900)
pam_smtpauth.c

index 0a268f4..b933d7d 100644 (file)
@@ -378,20 +378,22 @@ get_config(const char *filepath, char *param) {
         if(line[0] == '#' || line[0] == '\n') {
             continue;
         }
-        tstr = strstr(line, param);
-        if(tstr != NULL) {
-            result = malloc(strlen(tstr) + 1);
-            memset(result, 0, strlen(tstr) + 1);
-            for(i=0; tstr[i]!='='; i++) ;
-            i++;
-            while(tstr[i] == ' ' || tstr[i] == '"') {
+        if(strncmp(line, param, strlen(param)) == 0) {
+            tstr = strstr(line, param);
+            if(tstr != NULL) {
+                result = malloc(strlen(tstr) + 1);
+                memset(result, 0, strlen(tstr) + 1);
+                for(i=0; tstr[i]!='='; i++) ;
                 i++;
+                while(tstr[i] == ' ' || tstr[i] == '"') {
+                    i++;
+                }
+                for(j=0; tstr[i]!='\0' && tstr[i]!='\n'; i++,j++) {
+                    result[j] = tstr[i];
+                }
+                result[j] = '\0';
+                break;
             }
-            for(j=0; tstr[i]!='\0' && tstr[i]!='\n'; i++,j++) {
-                result[j] = tstr[i];
-            }
-            result[j] = '\0';
-            break;
         }
     }
     fclose(fp);