1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: xpm.C |
2 | * File: xpm.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1997 Carsten Haitzler <raster@zip.com.au> |
6 | * Copyright (c) 1997 Carsten Haitzler <raster@zip.com.au> |
7 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
7 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
8 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
8 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
|
|
9 | * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> |
9 | * |
10 | * |
10 | * This program is free software; you can redistribute it and/or modify |
11 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by |
12 | * it under the terms of the GNU General Public License as published by |
12 | * the Free Software Foundation; either version 2 of the License, or |
13 | * the Free Software Foundation; either version 2 of the License, or |
13 | * (at your option) any later version. |
14 | * (at your option) any later version. |
… | |
… | |
55 | int flags, changed = 0; |
56 | int flags, changed = 0; |
56 | int x = 0, y = 0; |
57 | int x = 0, y = 0; |
57 | unsigned int w = 0, h = 0; |
58 | unsigned int w = 0, h = 0; |
58 | unsigned int n; |
59 | unsigned int n; |
59 | char *p; |
60 | char *p; |
60 | bgPixmap_t *bgpixmap = & (bgPixmap); |
61 | bgPixmap_t *bgpixmap = &bgPixmap; |
61 | |
62 | |
62 | #define MAXLEN_GEOM sizeof("[10000x10000+10000+10000]") |
63 | #define MAXLEN_GEOM sizeof("[10000x10000+10000+10000]") |
63 | |
64 | |
64 | if (geom == NULL) |
65 | if (geom == NULL) |
65 | return 0; |
66 | return 0; |
… | |
… | |
77 | |
78 | |
78 | if ((p = strchr (geom, ';')) == NULL) |
79 | if ((p = strchr (geom, ';')) == NULL) |
79 | p = strchr (geom, '\0'); |
80 | p = strchr (geom, '\0'); |
80 | |
81 | |
81 | n = (p - geom); |
82 | n = (p - geom); |
82 | if (n <= MAXLEN_GEOM) |
83 | if (n < MAXLEN_GEOM) |
83 | { |
84 | { |
84 | strncpy (str, geom, n); |
85 | strncpy (str, geom, n); |
85 | str[n] = '\0'; |
86 | str[n] = '\0'; |
86 | |
87 | |
87 | flags = XParseGeometry (str, &x, &y, &w, &h); |
88 | flags = XParseGeometry (str, &x, &y, &w, &h); |