~ubuntu-branches/ubuntu/karmic/trousers/karmic

« back to all changes in this revision

Viewing changes to tools/ps_inspect.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-01-23 22:03:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080123220300-fhtqja3c0oq0gp6z
Tags: 0.3.1-4
* Added patch from Aaron M. Ucko <ucko@debian.org> to allow trousers to
  build successfully on amd64, and presumably also other 64-bit
  architectures (Closes: #457400).
* Including udev rule for /dev/tpm from William Lima
  <wlima.amadeus@gmail.com> as suggested by David Smith <dds@google.com>
  (Closes: #459682).
* Added lintian overrides.

Show diffs side-by-side

added added

removed removed

Lines of Context:
227
227
        PRINT("version:        1\n");
228
228
        PRINT("number of keys: %u\n", u32);
229
229
 
230
 
        if (u32 == 0)
231
 
                return 0;
232
 
 
233
230
        /* align the beginning of the buffer with the beginning of the key */
234
231
        memcpy(buf, &buf[5], sizeof(TSS_UUID));
235
232
 
261
258
        return 0;
262
259
}
263
260
 
264
 
/* the smallest key on disk should be around 600 bytes total
265
 
 * and the largest should be about 1000 bytes, so if the number
 
261
/* the smallest key on disk should be around 360 bytes total
 
262
 * and the largest should be about 560 bytes, so if the number
266
263
 * of keys is not in this ballpark, this is probably not a PS
267
264
 * file
268
265
 */
269
266
int
270
267
bad_file_size(UINT32 num_keys, off_t file_size)
271
268
{
272
 
        if ((num_keys * 600) > (unsigned long)file_size)
 
269
        if ((num_keys * 360) > (unsigned long)file_size)
273
270
                return 1;
274
271
 
275
 
        if ((num_keys * 1000) < (unsigned long) (file_size - (sizeof(UINT32) + 1)))
 
272
        if ((num_keys * 560) < (unsigned long)file_size)
276
273
                return 1;
277
274
 
278
275
        return 0;
284
281
        int members = 0;
285
282
        UINT32 *num_keys;
286
283
 
287
 
        if (!file_size) {
288
 
                printf("File is empty.\n");
289
 
                return 0;
290
 
        }
291
 
 
292
284
        /* do the initial read, which should include sizeof(TSS_UUID)
293
285
         * + sizeof(UINT32) + 1 bytes */
294
286
        if ((members = fread(buf,
295
 
                        sizeof(TSS_UUID) + sizeof(UINT32) + 1, 1, f)) != 1) {
296
 
                if (ferror(f)) {
297
 
                        fprintf(stderr, "Error during read.\n");
298
 
                        return -1;
299
 
                }
 
287
                        sizeof(TSS_UUID) + sizeof(UINT32) + 1,
 
288
                        1, f)) != 1) {
 
289
                printf("File is empty.\n");
 
290
                return -1;
300
291
        }
301
292
 
302
293
        if (buf[0] == '\1') {
303
294
                num_keys = (UINT32 *)&buf[1];
304
 
                if (bad_file_size(*num_keys, file_size))
 
295
                if (*num_keys == 0 || bad_file_size(*num_keys, file_size))
305
296
                        goto version0;
306
297
 
307
298
                return version_1_print(f);