- Timestamp:
- Mar 28, 2009, 5:00:34 PM (16 years ago)
- Branches:
- owl
- Children:
- 4de643d
- Parents:
- 5189631
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zcrypt.c
r9ceee9d rdab82f29 1 /* This file is stolen and slightly modified code */ 1 /* Copyright (c) 2002,2003,2004,2009 James M. Kretchmar 2 * 3 * This file is part of Owl. 4 * 5 * Owl is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * Owl is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with Owl. If not, see <http://www.gnu.org/licenses/>. 17 * 18 * --------------------------------------------------------------- 19 * 20 * As of Owl version 2.1.12 there are patches contributed by 21 * developers of the the branched BarnOwl project, Copyright (c) 22 * 2006-2008 The BarnOwl Developers. All rights reserved. 23 */ 24 25 /* The functions here with "owl" in their name were written for the 26 * Owl project. Other code is from Philip Lisiecki's 27 * (lisiecki@mit.edu) zcrypt program. 28 */ 2 29 3 30 /* zcrypt.c -- Read in a data stream from stdin & dump a decrypted/encrypted * … … 423 450 char *GetZephyrVarKeyFile(char *whoami, char *class, char *instance) { 424 451 char *keyfile = NULL; 425 char varname[MAX_SEARCH][128];452 char *varname[MAX_SEARCH]; 426 453 int length[MAX_SEARCH], i; 427 454 char buffer[MAX_BUFF]; 428 char filename[MAX_BUFF];455 char *filename; 429 456 char result[MAX_SEARCH][MAX_BUFF]; 430 457 int numsearch = 0; 431 458 FILE *fsearch; 432 459 460 memset(varname, 0, sizeof(varname)); 461 433 462 /* Determine names to look for in .crypt-table */ 434 463 if (instance) { 435 sprintf(varname[numsearch++],"crypt-%s-%s:", (class?class:"message"), instance);464 varname[numsearch++] = owl_sprintf("crypt-%s-%s:", (class?class:"message"), instance); 436 465 } 437 466 if (class) { 438 sprintf(varname[numsearch++],"crypt-%s:", class);439 } 440 sprintf(varname[numsearch++],"crypt-default:");467 varname[numsearch++] = owl_sprintf("crypt-%s:", class); 468 } 469 varname[numsearch++] = owl_strdup("crypt-default:"); 441 470 442 471 /* Setup the result array, and determine string lengths */ … … 447 476 448 477 /* Open~/.crypt-table */ 449 sprintf(filename,"%s/.crypt-table", getenv("HOME"));478 filename = owl_sprintf("%s/.crypt-table", getenv("HOME")); 450 479 fsearch = fopen(filename, "r"); 451 480 if (fsearch) { … … 495 524 } 496 525 526 for(i = 0; i < MAX_SEARCH; i++) { 527 owl_free(varname[i]); 528 } 529 530 owl_free(filename); 531 497 532 return(keyfile); 498 533 }
Note: See TracChangeset
for help on using the changeset viewer.