Index: modules/field/field.crud.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.crud.inc,v
retrieving revision 1.21
diff -u -r1.21 field.crud.inc
--- modules/field/field.crud.inc	14 Jul 2009 10:27:29 -0000	1.21
+++ modules/field/field.crud.inc	2 Aug 2009 16:42:10 -0000
@@ -212,7 +212,13 @@
     throw new FieldException('Attempt to create a field with invalid characters. Only alphanumeric characters and underscores are allowed.');
   }
 
-  // TODO: check that field_name < 32 chars.
+  // Field name cannot be longer than 32 characters
+  // We use drupal_strlen because the DB layer assumes that column widths
+  // are given in characters, not bytes.
+  if (drupal_strlen($field['field_name']) > 32) {
+  	throw new FieldException(t('Attempt to create a field with a name longer than 32 characters: %name',
+  	  array('%name' => $field['field_name'])));
+  }
 
   // Check that the field type is known.
   $field_type = field_info_field_types($field['type']);
@@ -233,6 +239,7 @@
     'locked' => FALSE,
     'settings' => array(),
   );
+  
   // Create all per-field-type properties (needed here as long as we have
   // settings that impact column definitions).
   $field['settings'] += field_info_field_settings($field['type']);
