~ubuntu-branches/ubuntu/saucy/gnutls28/saucy

« back to all changes in this revision

Viewing changes to lib/minitasn1/gstr.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-07-30 21:40:07 UTC
  • mfrom: (14.1.9 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130730214007-9mrd08xo61kla008
Tags: 3.2.3-1ubuntu1
* Sync with Debian (LP: #1068029). Remaining change:
  - Drop gnutls-bin and -doc since we want to use the versions
    in gnutls26 as the defaults instead

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    }
49
49
}
50
50
 
51
 
void
 
51
/* Returns the bytes copied (not including the null terminator) */
 
52
unsigned int
52
53
_asn1_str_cpy (char *dest, size_t dest_tot_size, const char *src)
53
54
{
54
55
  size_t str_size = strlen (src);
56
57
  if (dest_tot_size > str_size)
57
58
    {
58
59
      strcpy (dest, src);
 
60
      return str_size;
59
61
    }
60
62
  else
61
63
    {
62
64
      if (dest_tot_size > 0)
63
65
        {
64
 
          strncpy (dest, src, (dest_tot_size) - 1);
65
 
          dest[dest_tot_size - 1] = 0;
 
66
          str_size = dest_tot_size - 1;
 
67
          memcpy (dest, src, str_size);
 
68
          dest[str_size] = 0;
 
69
          return str_size;
66
70
        }
 
71
      else return 0;
67
72
    }
68
73
}