memmove min lengths
authordrh <drh@0d961d1b-a432-0410-8fea-cc29f225fe07>
Fri, 25 Jun 2004 18:36:05 +0000 (18:36 +0000)
committerdrh <drh@0d961d1b-a432-0410-8fea-cc29f225fe07>
Fri, 25 Jun 2004 18:36:05 +0000 (18:36 +0000)
git-svn-id: https://modwaklog.svn.sourceforge.net/svnroot/modwaklog/trunk/modwaklog@27 0d961d1b-a432-0410-8fea-cc29f225fe07

mod_waklog.c

index 474a17b..5fb26a1 100644 (file)
@@ -399,7 +399,7 @@ cleanup:
 waklog_aklog( request_rec *r )
 {
     int                                rc;
-    char                       buf[ 2048 ];
+    char                       buf[ MAXKTCTICKETLEN ];
     const char                 *k4path = NULL;
     const char                 *k5path = NULL;
     krb5_error_code            kerror;
@@ -507,19 +507,22 @@ waklog_aklog( request_rec *r )
                "mod_waklog: client: %s", buf );
 
        /* build the name */
-       memmove( buf, v5credsp->client->data[0].data, v5credsp->client->data[0].length );
+       memmove( buf, v5credsp->client->data[0].data,
+               min( v5credsp->client->data[0].length, MAXKTCNAMELEN - 1 ) );
        buf[ v5credsp->client->data[0].length ] = '\0';
        if ( v5credsp->client->length > 1 ) {
                strncat( buf, ".", sizeof( buf ) - strlen( buf ) - 1 );
                buflen = strlen( buf );
-               memmove( buf + buflen, v5credsp->client->data[1].data, v5credsp->client->data[1].length );
+               memmove( buf + buflen, v5credsp->client->data[1].data,
+                       min( v5credsp->client->data[1].length, MAXKTCNAMELEN - strlen( buf ) - 1 ) );
                buf[ buflen + v5credsp->client->data[1].length ] = '\0';
        }
 
        /* assemble the client */
        strncpy( client.name, buf,              sizeof( client.name ) - 1 );
        strncpy( client.instance, "",           sizeof( client.instance) - 1 );
-       memmove( buf, v5credsp->client->realm.data, v5credsp->client->realm.length );
+       memmove( buf, v5credsp->client->realm.data, 
+               min( v5credsp->client->realm.length, MAXKTCNAMELEN - 1 ) );
        buf[ v5credsp->client->realm.length ] = '\0';
        strncpy( client.cell, buf,              sizeof( client.cell ) - 1 );