Browse code

pwdb: added name tracking the pwdb entry

Kevin Lin authored on 2015/07/15 06:23:43
Showing 2 changed files
... ...
@@ -231,6 +231,7 @@ struct cli_dbinfo {
231 231
 };
232 232
 
233 233
 struct cli_pwdict {
234
+    char *name;
234 235
     unsigned char *passwd;
235 236
     uint16_t length;
236 237
     cli_file_t container;
... ...
@@ -4168,6 +4168,16 @@ static int cli_loadpwdb(FILE *fs, struct cl_engine *engine, unsigned int options
4168 4168
                 FREE_TDB(tdb);
4169 4169
                 break;
4170 4170
             }
4171
+
4172
+            /* copy passwd name */
4173
+            new->name = cli_mpool_strdup(engine->mempool, tokens[0]);
4174
+            if (!new->name) {
4175
+                ret = CL_EMEM;
4176
+                FREE_TDB(tdb);
4177
+                mpool_free(engine->mempool, new);
4178
+                break;
4179
+            }
4180
+
4171 4181
             if(pwstype == 0) { /* cleartext */
4172 4182
                 new->passwd = cli_mpool_strdup(engine->mempool, tokens[3]);
4173 4183
                 new->length = strlen(tokens[3]);
... ...
@@ -4183,6 +4193,7 @@ static int cli_loadpwdb(FILE *fs, struct cl_engine *engine, unsigned int options
4183 4183
                     ret = CL_EMALFDB;
4184 4184
                 FREE_TDB(tdb);
4185 4185
                 mpool_free(engine->mempool, new);
4186
+                mpool_free(engine->mempool, new->name);
4186 4187
                 break;
4187 4188
             }
4188 4189