[Freeciv-Dev] Re: Attribute.c fixes (PR#1217)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Thu, Jan 10, 2002 at 11:33:53AM +0100, Raimar Falke wrote:
The attached patch removes a guard and documents the way to query the
size of an attribute.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"If at first you don't succeed... well so much for skydiving."
? 1217_fix1.diff
? 1684_fix1.diff
? a
? city_turns_to_grow-2.diff
? die1.diff
? diff
? genlist1.diff
? include_fix1.diff
? log
? packet_size1.diff
? test.c
? warnings_A_1.diff
Index: client/attribute.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/attribute.c,v
retrieving revision 1.15
diff -u -r1.15 attribute.c
--- client/attribute.c 2002/09/28 01:36:19 1.15
+++ client/attribute.c 2002/11/17 16:51:03
@@ -323,8 +323,10 @@
/****************************************************************************
Low-level function to get an attribute. If data hasn't enough space
- to hold the attribute attribute_get aborts. Returns the actual size
- of the attribute. Can be zero if the attribute is unset.
+ to hold the attribute data isn't set to the attribute. Returns the
+ actual size of the attribute. Can be zero if the attribute is
+ unset. To get the size of an attribute use
+ size = attribute_get(key, id, x, y, 0, NULL)
*****************************************************************************/
size_t attribute_get(int key, int id, int x, int y, size_t max_data_length,
void *data)
@@ -356,21 +358,9 @@
dio_input_init(&din, pvalue, 0xffffffff);
dio_get_uint32(&din, &length);
- if(max_data_length < length){
- freelog(LOG_FATAL, "attribute: max_data_length=%d, length found=%d (!)\n"
- "It is quite possible that the server (this client was attached to) "
- "loaded an old savegame that was created prior to "
- "certain interface changes in your client. If you have access to "
- "the savegame, editing the file and removing entries beginning with "
- "\"attribute_block_\" may alleviate the problem (though you will "
- "lose some non-critical client data). If you still encounter this, "
- "submit a bug report to <freeciv-dev@xxxxxxxxxxx>",
- (unsigned int) max_data_length, length);
-
- exit(EXIT_FAILURE);
+ if (length <= max_data_length) {
+ dio_get_memory(&din, data, length);
}
-
- dio_get_memory(&din, data, length);
freelog(ATTRIBUTE_LOG_LEVEL, " found length=%d", length);
return length;
|
|