~ubuntu-branches/ubuntu/utopic/dropbear/utopic-proposed

« back to all changes in this revision

Viewing changes to svr-authpubkey.c

  • Committer: Bazaar Package Importer
  • Author(s): Matt Johnston
  • Date: 2005-12-08 19:20:21 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051208192021-nyp9rwnt77nsg6ty
Tags: 0.47-1
* New upstream release.
* SECURITY: Fix incorrect buffer sizing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
 
65
65
        /* 0 indicates user just wants to check if key can be used, 1 is an
66
66
         * actual attempt*/
67
 
        testkey = (buf_getbyte(ses.payload) == 0);
 
67
        testkey = (buf_getbool(ses.payload) == 0);
68
68
 
69
69
        algo = buf_getstring(ses.payload, &algolen);
70
70
        keybloblen = buf_getint(ses.payload);
266
266
 
267
267
        TRACE(("enter checkpubkeyperms"))
268
268
 
269
 
        assert(ses.authstate.pw);
270
269
        if (ses.authstate.pw->pw_dir == NULL) {
271
270
                goto out;
272
271
        }
312
311
/* returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
313
312
static int checkfileperm(char * filename) {
314
313
        struct stat filestat;
 
314
        int badperm = 0;
315
315
 
316
316
        TRACE(("enter checkfileperm(%s)", filename))
317
317
 
322
322
        /* check ownership - user or root only*/
323
323
        if (filestat.st_uid != ses.authstate.pw->pw_uid
324
324
                        && filestat.st_uid != 0) {
325
 
                TRACE(("leave checkfileperm: wrong ownership"))
326
 
                return DROPBEAR_FAILURE;
 
325
                badperm = 1;
 
326
                TRACE(("wrong ownership"))
327
327
        }
328
328
        /* check permissions - don't want group or others +w */
329
329
        if (filestat.st_mode & (S_IWGRP | S_IWOTH)) {
330
 
                TRACE(("leave checkfileperm: wrong perms"))
 
330
                badperm = 1;
 
331
                TRACE(("wrong perms"))
 
332
        }
 
333
        if (badperm) {
 
334
                if (!ses.authstate.perm_warn) {
 
335
                        ses.authstate.perm_warn = 1;
 
336
                        dropbear_log(LOG_INFO, "%s must be owned by user or root, and not writable by others", filename);
 
337
                }
 
338
                TRACE(("leave checkfileperm: failure perms/owner"))
331
339
                return DROPBEAR_FAILURE;
332
340
        }
 
341
 
333
342
        TRACE(("leave checkfileperm: success"))
334
343
        return DROPBEAR_SUCCESS;
335
344
}