- Timestamp:
- Mar 17, 2010, 10:36:59 PM (15 years ago)
- Branches:
- master, release-1.10, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 49bc81e
- Parents:
- 4942723
- git-author:
- Nelson Elhage <nelhage@mit.edu> (04/13/09 20:35:25)
- git-committer:
- Nelson Elhage <nelhage@ksplice.com> (03/17/10 22:36:59)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zcrypt.c
redae037 r6b1c3b6 8 8 9 9 #include <stdio.h> 10 #if defined(vax) || defined(ibm032) 11 #define pid_t int 12 int waitpid(pid_t pid, int *statloc, int options) 13 { 14 while (wait(statloc) != pid) 15 ; 16 } 17 #define STDIN_FILENO 0 18 #else 10 11 19 12 #include <unistd.h> 20 #endif21 13 #include <sys/types.h> 22 14 #include <des.h> 23 15 #include <zephyr/zephyr.h> 16 #include <glib.h> 24 17 25 18 #define MAX_KEY 128 … … 321 314 int retval; 322 315 char *keyfile; 323 char varname[MAX_SEARCH][128];316 char *varname[MAX_SEARCH]; 324 317 int length[MAX_SEARCH], i; 325 318 char buffer[MAX_BUFF]; 326 char filename[MAX_BUFF];319 char *filename; 327 320 char result[MAX_SEARCH][MAX_BUFF]; 328 321 int numsearch = 0; 329 322 FILE *fsearch; 330 323 324 memset(varname, 0, sizeof(varname)); 325 331 326 /* Determine names to look for in .crypt-table */ 332 327 if (instance) 333 sprintf(varname[numsearch++], "crypt-%s-%s:", (class?class:"message"), 334 instance); 328 varname[numsearch++] = g_strdup_printf("crypt-%s-%s:", (class?class:"message"), instance); 335 329 if (class) 336 sprintf(varname[numsearch++],"crypt-%s:", class);337 sprintf(varname[numsearch++], "crypt-default:", class);330 varname[numsearch++] = g_strdup_printf("crypt-%s:", class); 331 varname[numsearch++] = g_strdup("crypt-default:"); 338 332 339 333 /* Setup the result array, and determine string lengths */ … … 345 339 346 340 /* Open~/.crypt-table */ 347 sprintf(filename,"%s/.crypt-table", getenv("HOME"));341 filename = g_strdup_printf("%s/.crypt-table", getenv("HOME")); 348 342 fsearch = fopen(filename, "r"); 349 343 if (fsearch) … … 394 388 else 395 389 printf("Could not open key table file: %s\n", filename); 390 391 for(i = 0; i < MAX_SEARCH; i++) { 392 if(varname[i] != NULL) { 393 g_free(varname[i]); 394 } 395 } 396 397 if(filename != NULL) { 398 g_free(filename); 399 } 396 400 397 401 return keyfile;
Note: See TracChangeset
for help on using the changeset viewer.